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
How to Write a Method That Counts the Most Common Substring in a String in Ruby
Heroku Deplyoment Asset Precompiling Failed on Rails 6
Mongomapper Many to Many Issue with Array
When Joining Table, Rails Anyway Makes Additional Request When Accessing Fields from Joined Table
Knowing When Resque Worker Had Completed Job
Ruby on Rails Updating Heroku Dynamic Routes
When Trying to Run Rspec, I Get "Uninitialized Constant Activemodel"
Check Whether a Variable Is a String in Ruby
How to Get Unique Elements in This Array
When Passing a Ruby Array as an Argument, Why Does '<<' Append While '+=' Does Not
Attr_Accessor, Not Able to Access Property
Consolidating Duplicate Array Items
Delete from Database with Specific Details in Ruby
Ruby Before_Validation Triggers Infinite Loop of Call Back
Slicing of Arrays in Ruby Returns Different Result - Nil VS. Empty Array