Created
June 26, 2017 09:58
-
-
Save matthewrudy/d6c4c3709ff3d61ee24d7eb7aa117c9f to your computer and use it in GitHub Desktop.
Running headless chrome on capybara with selenium webdriver
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
require "selenium/webdriver" | |
Capybara.register_driver :chrome do |app| | |
Capybara::Selenium::Driver.new(app, browser: :chrome) | |
end | |
Capybara.register_driver :headless_chrome do |app| | |
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( | |
chromeOptions: { args: %w(headless disable-gpu) } | |
) | |
Capybara::Selenium::Driver.new app, | |
browser: :chrome, | |
desired_capabilities: capabilities | |
end | |
Capybara.default_driver = ENV['CODESHIP'] ? :chrome : :headless_chrome |
Thanks for this @lcguida and @alazycoder101 . 👊🚀
This worked for me, with no deprecation errors:
Capybara.register_driver :headless_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new(
args: %w[headless no-sandbox disable-gpu disable-dev-shm-usage],
)
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
options: options
)
end
Thanks @sytzez 🙏
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For some reason headless is not working for me. I have to use the following one: