-
-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Chromedriver truly headless #982
Make Chromedriver truly headless #982
Conversation
When I use Suspenders' configuration on a new project, JavaScript tests open up the Chrome app in a real window. When using the configuration in this commit, Chrome quietly bounces once, in the taskbar (on macOS), and does not create a window.
I just started a new project and was frustrated to see my tests open up a non-headless chrome. I was excited to see this PR, but unfortunately the change had no effect for me. Was there anything else you needed to do to get this working? |
Maybe the version of Chrome matters? I'm using:
There is technically slightly more stuff in my require "selenium/webdriver"
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Capybara.register_driver :headless_chrome do |app|
options = ::Selenium::WebDriver::Chrome::Options.new
options.headless!
# Set a big (15" MBP retina resolution) window size so that
# `save_and_open_screenshot` captures the whole page.
options.add_argument '--window-size=1680,1050'
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { args: %w(headless disable-gpu) },
loggingPrefs: {
browser: 'ALL'
}
)
Capybara::Selenium::Driver.new app,
browser: :chrome,
options: options,
desired_capabilities: capabilities
end
Capybara.javascript_driver = :headless_chrome
# Silence Puma's startup message in specs
# https://github.com/rspec/rspec-rails/issues/1897
Capybara.server = :puma, { Silent: true } |
I can confirm that this PR makes my tests go headless. Anyway, I remember I was able to run them headless without this PR, but now I need this PR. So maybe it depends on a newever Chrome version? I'm wondering what
|
OK, I updated all the things and this is working for me now. After a bit of digging, I am not convinced the It may also be fine to lose the disable-gpu options. I am not sure exactly why that option was there in the first place, but Selenium was using it as a workaround for windows and removed it in SeleniumHQ/selenium#6943. |
I confirm that on macOS, with Chrome 75, using just |
Thanks! |
When I use Suspenders' configuration on a new project, JavaScript tests open up the Chrome app in a real window (i.e. not headless).
When using the configuration in this commit, Chrome quietly bounces once, in the taskbar (on macOS), and does not create a window.