Class: WatchDoge::WebdriverManager

Inherits:
Object
  • Object
show all
Defined in:
lib/watchdoge/webdriver_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(browser) ⇒ WebdriverManager

Returns a new instance of WebdriverManager.


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# 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

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver


14
15
16
# File 'lib/watchdoge/webdriver_manager.rb', line 14

def driver
  @driver
end

#install_pathObject (readonly)

Returns the value of attribute install_path


16
17
18
# File 'lib/watchdoge/webdriver_manager.rb', line 16

def install_path
  @install_path
end

#install_versionObject (readonly)

Returns the value of attribute install_version


15
16
17
# File 'lib/watchdoge/webdriver_manager.rb', line 15

def install_version
  @install_version
end