Class: ProxyRb::Drivers::WebkitDriver

Inherits:
BasicDriver show all
Defined in:
lib/proxy_rb/drivers/webkit_driver.rb

Overview

Driver for Capybara-Webkit

Instance Method Summary collapse

Methods inherited from BasicDriver

#configure_driver

Instance Method Details

#failure_errorsObject



56
57
58
59
60
61
62
# File 'lib/proxy_rb/drivers/webkit_driver.rb', line 56

def failure_errors
  [
    Capybara::Webkit::InvalidResponseError,
    Capybara::Webkit::NoResponseError,
    Capybara::Webkit::ConnectionError
  ]
end

#register(proxy) ⇒ Object

Register proxy

Parameters:

  • proxy (HttpProxy)

    The HTTP proxy which should be used for fetching content



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/proxy_rb/drivers/webkit_driver.rb', line 28

def register(proxy)
  if proxy.empty?
    ::Capybara.current_driver = :webkit
    return
  end

  options = {
    proxy: {
      host: proxy.host,
      port: proxy.port,
      user: proxy.user,
      pass: proxy.password
    }
  }

  unless ::Capybara.drivers.key? proxy.to_ref
    ::Capybara.register_driver proxy.to_ref do |app|
      ::Capybara::Webkit::Driver.new(app, Capybara::Webkit::Configuration.to_hash.merge(options))
    end
  end

  ::Capybara.current_driver = proxy.to_ref
end

#timeout_errorsObject



52
53
54
# File 'lib/proxy_rb/drivers/webkit_driver.rb', line 52

def timeout_errors
  [::Capybara::Webkit::TimeoutError]
end