class WatchDoge::WebdriverManager

Attributes

driver[R]
install_path[R]
install_version[R]

Public Class Methods

new(browser) click to toggle source
# File lib/watchdoge/webdriver_manager.rb, line 18
def initialize browser
  @driver =
    case browser
    when :chrome
      Webdrivers::Chromedriver
    when :firefox
      Webdrivers::Geckodriver
    end

  @install_version = WatchDoge.configuration.send("#{browser}_version") || @driver.latest_version.to_s

  @install_path = "#{WatchDoge.configuration.web_drivers_dir}/#{browser}/#{@install_version}/"
  Webdrivers.install_dir = @install_path

  @driver.required_version = @install_version

  @driver.update

  klass = "Selenium::WebDriver::#{browser.to_s.split('_').collect(&:capitalize).join}::Service".constantize
  binary =
    case browser
    when :chrome
      "chromedriver"
    when :firefox
      "geckodriver"
    end

  klass.driver_path = "#{@install_path}/#{binary}"
end