Last active
October 28, 2018 01:46
-
-
Save ruyrocha/4cde4bb454b61e941790071cf696a180 to your computer and use it in GitHub Desktop.
Capybara with headless Chrome
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
Capybara.register_driver :chrome do |app| | |
# Ensure a reasonable amount of time for Read/Open timeouts | |
http_client = Selenium::WebDriver::Remote::Http::Default.new( | |
read_timeout: 30, | |
open_timeout: 30 | |
) | |
# Explicitly set the Chrome capabilities | |
browser_capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( | |
'chromeOptions' => { | |
'args' => [ | |
'headless', | |
'no-sandbox', | |
'disable-gpu', | |
'window-size=1920,1080', | |
'disable-setuid-sandbox' | |
] | |
} | |
) | |
Capybara::Selenium::Driver.new( | |
app, | |
http_client: http_client, | |
browser: :chrome, | |
desired_capabilities: browser_capabilities | |
) | |
end | |
Capybara.javascript_driver = :chrome | |
Capybara.default_max_wait_time = 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment