Class: Webdrivers::MSWebdriver

Inherits:
Common
  • Object
show all
Defined in:
lib/webdrivers/mswebdriver.rb

Class Method Summary collapse

Methods inherited from Common

binary, desired_version, download, install_dir, latest_version, remove, update

Class Method Details

.version=Object



26
27
28
# File 'lib/webdrivers/mswebdriver.rb', line 26

def version=(*)
  raise 'Version can not be set for MSWebdriver because it is dependent on the version of Edge'
end

.windows_versionObject Also known as: version



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/webdrivers/mswebdriver.rb', line 4

def windows_version
  Webdrivers.logger.debug 'Checking current version'

  # current_version() from other webdrivers returns the version from the webdriver EXE.
  # Unfortunately, MicrosoftWebDriver.exe does not have an option to get the version.
  # To work around it we query the currently installed version of Microsoft Edge instead
  # and compare it to the list of available downloads.
  version = `powershell (Get-AppxPackage -Name Microsoft.MicrosoftEdge).Version`
  raise 'Failed to check Microsoft Edge version.' if version.empty? # Package name changed?

  Webdrivers.logger.debug "Current version of Microsoft Edge is #{version.chomp!}"

  build = version.split('.')[1] # "41.16299.248.0" => "16299"
  Webdrivers.logger.debug "Expecting MicrosoftWebDriver.exe version #{build}"
  build.to_i
end