class Selenium::WebDriver::DriverFinder
Public Class Methods
new(options, service)
click to toggle source
# File lib/selenium/webdriver/common/driver_finder.rb, line 29 def initialize(options, service) @options = options @service = service end
path(options, service_class)
click to toggle source
# File lib/selenium/webdriver/common/driver_finder.rb, line 23 def self.path(options, service_class) WebDriver.logger.deprecate('DriverFinder.path(options, service_class)', 'DriverFinder.new(options, service).driver_path') new(options, service_class.new).driver_path end
Public Instance Methods
browser_path()
click to toggle source
# File lib/selenium/webdriver/common/driver_finder.rb, line 34 def browser_path paths[:browser_path] end
browser_path?()
click to toggle source
# File lib/selenium/webdriver/common/driver_finder.rb, line 42 def browser_path? !browser_path.nil? && !browser_path.empty? end
driver_path()
click to toggle source
# File lib/selenium/webdriver/common/driver_finder.rb, line 38 def driver_path paths[:driver_path] end
Private Instance Methods
paths()
click to toggle source
# File lib/selenium/webdriver/common/driver_finder.rb, line 48 def paths @paths ||= begin path = @service.class.driver_path path = path.call if path.is_a?(Proc) exe = @service.class::EXECUTABLE if path WebDriver.logger.debug("Skipping Selenium Manager; path to #{exe} specified in service class: #{path}") Platform.assert_executable(path) {driver_path: path} else output = SeleniumManager.binary_paths(*to_args) formatted = {driver_path: Platform.cygwin_path(output['driver_path'], only_cygwin: true), browser_path: Platform.cygwin_path(output['browser_path'], only_cygwin: true)} Platform.assert_executable(formatted[:driver_path]) browser_path = formatted[:browser_path] Platform.assert_executable(browser_path) if @options.respond_to?(:binary) && @options.binary.nil? @options.binary = browser_path @options.browser_version = nil end formatted end rescue StandardError => e WebDriver.logger.error("Exception occurred: #{e.message}") WebDriver.logger.error("Backtrace:\n\t#{e.backtrace&.join("\n\t")}") raise Error::NoSuchDriverError, "Unable to obtain #{exe}" end end
to_args()
click to toggle source
# File lib/selenium/webdriver/common/driver_finder.rb, line 79 def to_args args = ['--browser', @options.browser_name] if @options.browser_version args << '--browser-version' args << @options.browser_version end if @options.respond_to?(:binary) && !@options.binary.nil? args << '--browser-path' args << @options.binary.gsub('\\', '\\\\\\') end if @options.proxy args << '--proxy' args << (@options.proxy.ssl || @options.proxy.http) end args end