Last active
May 1, 2024 21:29
-
-
Save jasoncodes/6025475 to your computer and use it in GitHub Desktop.
Remote Chrome browser for Capybara
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On the shared machine: | |
Download http://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.33.0.jar&can=2&q= | |
$ brew install chromedriver | |
$ java -jar selenium-server-standalone-2.33.0.jar | |
On the local machine: | |
Set `CHROME_HOSTNAME` in your `.env`, `.rbenv_vars`, or per run. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ENV['CHROME_HOSTNAME'].present? | |
Capybara.register_driver :chrome do |app| | |
Capybara::Selenium::Driver.new(app, | |
:browser => :remote, | |
:desired_capabilities => :chrome, | |
:url => "http://#{ENV['CHROME_HOSTNAME']}:4444/wd/hub" | |
) | |
end | |
Capybara.server_port = Capybara::Server.new(Rails.application).send(:find_available_port) | |
Capybara.app_host = "http://#{`hostname -s`.strip}.local:#{Capybara.server_port}" | |
else | |
Capybara.register_driver :chrome do |app| | |
Capybara::Selenium::Driver.new(app, :browser => :chrome) | |
end | |
end | |
Capybara.default_wait_time = 5 | |
Capybara.javascript_driver = :chrome |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment