Class: ProxyRb::Drivers::PoltergeistDriver

Inherits:
BasicDriver
  • Object
show all
Defined in:
lib/proxy_rb/drivers/poltergeist_driver.rb

Overview

Driver for Poltergeist

Instance Method Summary collapse

Methods inherited from BasicDriver

#configure_driver

Instance Method Details

#failure_errorsObject



53
54
55
# File 'lib/proxy_rb/drivers/poltergeist_driver.rb', line 53

def failure_errors
  [::Capybara::Poltergeist::StatusFailError]
end

#register(proxy) ⇒ Object

Register proxy

Parameters:

  • proxy (HttpProxy)

    The HTTP proxy which should be used for fetching content



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/proxy_rb/drivers/poltergeist_driver.rb', line 24

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

  cli_parameters = []
  cli_parameters << "--proxy=#{proxy.url}" unless proxy.url.empty?
  cli_parameters << "--proxy-auth=#{proxy.credentials}" unless proxy.credentials.empty?

  options = {
    phantomjs_options: cli_parameters,
    js_errors: false,
    phantomjs_logger: $stderr
  }

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

  ::Capybara.current_driver = proxy.to_ref
end

#timeout_errorsObject



49
50
51
# File 'lib/proxy_rb/drivers/poltergeist_driver.rb', line 49

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