Run Selenium tests in Chrome instead of Firefox

Posted Almost 13 years ago. Visible to the public.

Here is how to switch your Selenium to Chrome:

  1. Make sure you've got a recent version of chromedriver Show archive.org snapshot in your $PATH

See also geordi chromedriver_update Show archive.org snapshot which is automatically executed before every usage of geordi cucumber.

  1. Register Driver:

Create a file features/support/capybara.rb with the following content for recent version of Capybara:

Capybara.register_driver :selenium do |app|
  Capybara::Selenium::Driver.new(app, browser: :chrome)
end

Legacy Capybara setup

If you have an older Capybara version you need to say:

Capybara.javascript_driver = :selenium

Capybara::Driver::Selenium.class_eval do
  cattr_accessor :driver
end

driver = Selenium::WebDriver.for :chrome

Capybara::Driver::Selenium.driver = driver

at_exit do
  driver.close
end
Henning Koch
Last edit
10 months ago
Felix Eschey
Keywords
cucumber
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2011-07-05 09:50)