Module: OnlyofficeWebdriverWrapper::ChromeVersionHelper

Included in:
ChromeHelper
Defined in:
lib/onlyoffice_webdriver_wrapper/helpers/chrome_helper/chrome_version_helper.rb

Overview

Class for getting chrome version

Instance Method Summary collapse

Instance Method Details

#chrome_version(chrome_command = 'google-chrome') ⇒ Gem::Version

Returns version of chrome. Return unknown_chrome_version if cannot get.

Returns:

  • (Gem::Version)

    version of chrome. Return unknown_chrome_version if cannot get



12
13
14
15
16
17
18
19
20
21
# File 'lib/onlyoffice_webdriver_wrapper/helpers/chrome_helper/chrome_version_helper.rb', line 12

def chrome_version(chrome_command = 'google-chrome')
  return @chrome_version if @chrome_version

  version_string = `#{chrome_command} --product-version`
  OnlyofficeLoggerHelper.log("Chrome Version is: #{version_string}")
  @chrome_version = Gem::Version.new(version_string)
rescue StandardError => e
  OnlyofficeLoggerHelper.log("Cannot get chrome version because of: #{e}")
  @chrome_version = unknown_chrome_version
end

#chromedriver_path(force_os = nil) ⇒ String

Returns path to chromedriver.

Parameters:

  • force_os (Symbol) (defaults to: nil)

    force OS for chrome version (‘:linux` or `:mac`), if empty - will try to autodetect current os

Returns:

  • (String)

    path to chromedriver



26
27
28
29
30
31
# File 'lib/onlyoffice_webdriver_wrapper/helpers/chrome_helper/chrome_version_helper.rb', line 26

def chromedriver_path(force_os = nil)
  return default_mac if OSHelper.mac? || force_os == :mac
  return default_linux if (chrome_version == unknown_chrome_version) || force_os == :linux

  chromedriver_path_for_version(chrome_version.segments.first)
end

#unknown_chrome_versionGem::Version

Returns unknown chrome version.

Returns:

  • (Gem::Version)

    unknown chrome version



7
8
9
# File 'lib/onlyoffice_webdriver_wrapper/helpers/chrome_helper/chrome_version_helper.rb', line 7

def unknown_chrome_version
  Gem::Version.new('0.0.0.0')
end