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

.cache_warningObject (readonly)

Returns the value of attribute cache_warning


58
59
60
# File 'lib/webdrivers/common.rb', line 58

def cache_warning
  @cache_warning
end

.required_versionGem::Version

Returns the user defined required version.

Returns:

  • (Gem::Version)

74
75
76
# File 'lib/webdrivers/common.rb', line 74

def required_version
  normalize_version @required_version
end

Class Method Details

.binaryObject


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

def binary
  Webdrivers.logger.deprecate('#binary', '#driver_path')
  driver_path
end

.desired_versionObject


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

def desired_version
  old = "#{self.class}#desired_version"
  new = "#{self.class}#required_version or #{self.class}#latest_version"
  Webdrivers.logger.deprecate(old, new)

  desired_version == EMPTY_VERSION ? latest_version : normalize_version(desired_version)
end

.downloadObject


110
111
112
113
# File 'lib/webdrivers/common.rb', line 110

def download
  Webdrivers.logger.deprecate('#download', '#update')
  System.download(download_url, driver_path)
end

.driver_pathString

Returns path to the driver binary.

Returns:

  • (String)

124
125
126
# File 'lib/webdrivers/common.rb', line 124

def driver_path
  File.join System.install_dir, file_name
end

.removeObject

Deletes the existing driver binary.


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

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.


82
83
84
85
86
87
88
89
90
# File 'lib/webdrivers/common.rb', line 82

def update
  if correct_binary?
    Webdrivers.logger.debug 'The required webdriver version is already on the system'
    return driver_path
  end

  remove
  System.download(download_url, driver_path)
end

.versionObject


60
61
62
63
# File 'lib/webdrivers/common.rb', line 60

def version
  Webdrivers.logger.deprecate("#{self.class}#version", "#{self.class}#required_version")
  required_version
end

.version=(version) ⇒ Object


65
66
67
68
# File 'lib/webdrivers/common.rb', line 65

def version=(version)
  Webdrivers.logger.deprecate("#{self.class}#version=", "#{self.class}#required_version=")
  self.required_version = version
end