Class: Selenium::WebDriver::DriverFinder
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | rb/lib/selenium/webdriver/common/driver_finder.rb |
Class Method Summary
Instance Attribute Summary
- #browser_path readonly
- #browser_path? ⇒ Boolean readonly
Instance Method Summary
- #driver_path
- #class_path private
- #env_path private
- #paths private
- #paths_from_manager private
- #paths_from_service(path) private
- #to_args private
Constructor Details
.new(options, service) ⇒ DriverFinder
# File 'rb/lib/selenium/webdriver/common/driver_finder.rb', line 31
def initialize(, service) @options = @service = service end
Class Method Details
.path(options, service_class)
[ GitHub ]Instance Attribute Details
#browser_path (readonly)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/driver_finder.rb', line 36
def browser_path paths[:browser_path] end
#browser_path? ⇒ Boolean (readonly)
[ GitHub ]
# File 'rb/lib/selenium/webdriver/common/driver_finder.rb', line 44
def browser_path? !browser_path.nil? && !browser_path.empty? end
Instance Method Details
#class_path (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/driver_finder.rb', line 65
def class_path path = @service.class.driver_path path.is_a?(Proc) ? path.call : path end
#driver_path
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/driver_finder.rb', line 40
def driver_path paths[:driver_path] end
#env_path (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/driver_finder.rb', line 61
def env_path ENV.fetch(@service.class::DRIVER_PATH_ENV_KEY, nil) end
#paths (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/driver_finder.rb', line 50
def paths @paths ||= begin path = @service.executable_path || env_path || class_path path ? paths_from_service(path) : paths_from_manager rescue StandardError => e WebDriver.logger.error("Exception occurred: #{e.}") WebDriver.logger.error("Backtrace:\n\t#{e.backtrace&.join("\n\t")}") raise Error::NoSuchDriverError, "Unable to obtain #{@service.class::EXECUTABLE}" end end
#paths_from_manager (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/driver_finder.rb', line 77
def paths_from_manager 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]) Platform.assert_executable(formatted[:browser_path]) formatted end
#paths_from_service(path) (private)
[ GitHub ]#to_args (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/driver_finder.rb', line 86
def to_args return ['--driver', @service.class::EXECUTABLE] unless @options 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