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

#register(proxy) ⇒ Object

Register proxy

Parameters:

  • proxy (HttpProxy) —

    The HTTP proxy which should be used for fetching content



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

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

#rescuable_errors ⇒ Object



47
48
49
# File 'lib/proxy_rb/drivers/poltergeist_driver.rb', line 47

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