Class: Webdrivers::Common

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

Direct Known Subclasses

Chromedriver, Geckodriver, IEdriver

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.required_versionGem::Version

Returns the user defined required version.

Returns:

  • (Gem::Version)

82
83
84
# File 'lib/webdrivers/common.rb', line 82

def required_version
  normalize_version(@required_version ||= nil)
end

Class Method Details

.driver_pathString

Returns path to the driver binary.

Returns:

  • (String)

115
116
117
# File 'lib/webdrivers/common.rb', line 115

def driver_path
  File.absolute_path File.join(System.install_dir, file_name)
end

.removeObject

Deletes the existing driver binary.


104
105
106
107
108
109
# File 'lib/webdrivers/common.rb', line 104

def remove
  @download_url = nil
  @latest_version = nil
  System.delete "#{System.install_dir}/#{file_name.gsub('.exe', '')}.version"
  System.delete driver_path
end

.updateString

Triggers an update check.

Returns:

  • (String)

    Path to the driver binary.


90
91
92
93
94
95
96
97
98
99
# File 'lib/webdrivers/common.rb', line 90

def update
  if correct_binary?
    msg = required_version != EMPTY_VERSION ?  'The required webdriver version' : 'A working webdriver version'
    Webdrivers.logger.debug "#{msg} is already on the system"
    return driver_path
  end

  remove
  System.download(download_url, driver_path)
end