EFForg / congress_forms

Other
5 stars 2 forks source link

Fix chrome options for ChromeDriver 75 #1

Closed vbrown608 closed 5 years ago

vbrown608 commented 5 years ago

https://github.com/flavorjones/chromedriver-helper was giving us an old version, 2.35. https://github.com/titusfortner/webdrivers is giving us version 75 (not as bad as it sounds, Chrome starting giving the drivers names that match the browser version at version 70).

I'm not sure where these options get parsed, but maybe the driver is being stricter now. In any case, this stops Selenium from trying to launch a headful browser on my sandbox.

vbrown608 commented 5 years ago

Ooh we should probably do it how Capabara does in their codebase (they have a preconfigured headless driver, but it might not work in Docker because of no-sandbox)

Capybara.register_driver :selenium_chrome_headless do |app|
  Capybara::Selenium::Driver.load_selenium
  browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
    opts.args << '--headless'
    opts.args << '--disable-gpu' if Gem.win_platform?
    # Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary
    opts.args << '--disable-site-isolation-trials'
  end
  Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end
vbrown608 commented 5 years ago

Actually, I think this is fine for getting this fix out.