Instantiate Capybara Browser and Set a Proxy

Block hosts with Capybara selenium

There is no black/whitelist support in the selenium driver, however if you use the puffing-billy gem it works with the selenium to autoconfigure a proxy that allows for black or whitelisting urls

Poltergeist toggle proxy during test runtime

It is not possible to disable/enable phantomjs options during runtime through poltergeist (though IIRC it is possible in general, so that feature could be added to poltergeist).

I think the easiest way to achieve this would be to register a new Capybara driver. E.g.

Capybara.register_driver :proxied_poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, phantomjs_options: [...])
end

You can then use the driver where applicable by setting Capybara.current_driver = :proxied_poltergeist. This will launch a separate phantomjs instance with the CLI options you specify.

Configure Capybara to use Marionette WebDriver for Firefox

marionette is passed an option to Driver.new - not to desired_capabilities

Capybara.register_driver :selenium_firefox do |app|
Capybara::Selenium::Driver.new(app, browser: :firefox, marionette: true)
end

It also requires you to have downloaded geckodriver, put it in your path and renamed it to wires

A complete description of these configuration steps, including Marionette latest executables download links can be found here.

Note: Capybara does not yet support marionette, some things are being fixed in capybara, some are bugs in selenium-webdriver, and others are just general flakiness of it - things like it just stops selecting options from select elements - no errors thrown, just stops working. I don't think its ready for real world use yet.

Capybara/Poltergeist HTTP Authentication

You can try

page.driver.basic_authorize(username, password)

before visiting the page in Poltergeist. That will set the username and password in phantomjs and also the 'Authorization' header



Related Topics



Leave a reply



Submit