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
14
15
16
17
# File 'lib/crabfarm/support/webdriver_factory.rb', line 8

def build_chrome_driver(_options={})
  switches = []

  if _options[:proxy].present?
    switches << "--proxy-server=#{_options[:proxy]}"
    switches << "--ignore-certificate-errors"
  end

  common_setup Selenium::WebDriver.for(:chrome, :switches => switches), _options
end

#build_firefox_driver(_options = {}) ⇒ Object



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

def build_firefox_driver(_options={})
  profile = Selenium::WebDriver::Firefox::Profile.new

  if _options[:proxy].present?
    profile.proxy = Selenium::WebDriver::Proxy.new({
      :http => _options[:proxy],
      :ssl => _options[:proxy]
    })
  end

  common_setup Selenium::WebDriver.for(:firefox, :profile => profile), _options
end

#build_remote_driver(_options = {}) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/crabfarm/support/webdriver_factory.rb', line 32

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

  if _options[:proxy].present?
    client.proxy = Selenium::WebDriver::Proxy.new({
      :http => _options[:proxy],
      :ssl => _options[:proxy]
    })
  end

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