Module: Crabfarm::Support::WebdriverFactory

Extended by:
WebdriverFactory
Included in:
WebdriverFactory
Defined in:
lib/crabfarm/support/webdriver_factory.rb

Instance Method Summary collapse

Instance Method Details

#build_chrome_driver(_options = {}) ⇒ Object



8
9
10
11
12
13
# File 'lib/crabfarm/support/webdriver_factory.rb', line 8

def build_chrome_driver(_options={})
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
  capabilities.proxy = build_proxy(_options) if _options[:proxy].present?

  setup_webdriver Selenium::WebDriver.for(:chrome, detach: false, desired_capabilities: capabilities), _options
end

#build_firefox_driver(_options = {}) ⇒ Object



15
16
17
18
19
20
# File 'lib/crabfarm/support/webdriver_factory.rb', line 15

def build_firefox_driver(_options={})
  capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
  capabilities.proxy = build_proxy(_options) if _options[:proxy].present?

  setup_webdriver Selenium::WebDriver.for(:firefox, desired_capabilities: capabilities), _options
end

#build_remote_driver(_options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/crabfarm/support/webdriver_factory.rb', line 22

def build_remote_driver(_options={})
  client = Selenium::WebDriver::Remote::Http::Default.new
  client.timeout = _options[:remote_timeout]
  client.proxy = build_proxy(_options) if _options[:proxy].present?

  setup_webdriver(Selenium::WebDriver.for(:remote, {
    :url => _options[:remote_host],
    :http_client => client,
    :desired_capabilities => _options[:capabilities] || Selenium::WebDriver::Remote::Capabilities.firefox
  }), _options)
end