Class: Webdrivers::Chromedriver

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

Class Method Summary collapse

Methods inherited from Common

binary, desired_version, download, driver_path, remove, update, version, version=

Class Method Details

.chrome_versionGem::Version

Returns currently installed Chrome/Chromium version.

Returns:

  • (Gem::Version)

Raises:


44
45
46
47
48
49
50
51
# File 'lib/webdrivers/chromedriver.rb', line 44

def chrome_version
  ver = send("chrome_on_#{System.platform}").chomp

  raise VersionError, 'Failed to find Chrome binary or its version.' if ver.nil? || ver.empty?

  Webdrivers.logger.debug "Browser version: #{ver}"
  normalize_version ver[/\d+\.\d+\.\d+\.\d+/] # Google Chrome 73.0.3683.75 -> 73.0.3683.75
end

.current_versionGem::Version

Returns current chromedriver version.

Returns:

  • (Gem::Version)

13
14
15
16
17
18
19
20
21
22
# File 'lib/webdrivers/chromedriver.rb', line 13

def current_version
  Webdrivers.logger.debug 'Checking current version'
  return nil unless exists?

  version = binary_version
  return nil if version.nil?

  # Matches 2.46, 2.46.628411 and 73.0.3683.75
  normalize_version version[/\d+\.\d+(\.\d+)?(\.\d+)?/]
end

.latest_versionGem::Version

Returns latest available chromedriver version.

Returns:

  • (Gem::Version)

28
29
30
31
32
33
34
35
36
37
38
# File 'lib/webdrivers/chromedriver.rb', line 28

def latest_version
  @latest_version ||= begin
    # Versions before 70 do not have a LATEST_RELEASE file
    return normalize_version('2.41') if release_version < normalize_version('70')

    latest_applicable = with_cache(file_name) { latest_point_release(release_version) }

    Webdrivers.logger.debug "Latest version available: #{latest_applicable}"
    normalize_version(latest_applicable)
  end
end