Is it possible to use HTTP proxies with capybara?

The Capybara API does not seem to support HTTP proxy configuration. Is there any way to use it with it?

Context: I use capybara with a cucumber to test the rails and akephalos application as a javascript driver. There is a tag on the page scriptthat makes a request to an external site (in this case, maps.google.com). The cucumber test fails with the following message:

org.apache.http.conn.HttpHostConnectException: Connection to http://maps.google.com refused (NativeException)
(drbunix:///tmp/akephalos.24700.sock) -e:1
./features/step_definitions/named_element_steps.rb:20
+3
source share
1 answer

I don't know about Akephalos, but this is certainly possible with Selenium / Firefox:

  Capybara.register_driver :selenium do |app|
    profile = Selenium::WebDriver::Firefox::Profile.new

    profile["network.proxy.type"] = 1 # manual proxy config
    profile["network.proxy.http"] = "http://example.com"
    profile["network.proxy.http_port"] = 80

    Capybara::Selenium::Driver.new(app, :profile => profile)
  end
+5
source

All Articles