Skip to content

Commit

Permalink
Merge pull request #371 from dgmstuart/dgms/selenium-bypass-chrome-se…
Browse files Browse the repository at this point in the history
…arch-engine-selection

Override Capybara selenium_chrome_headless driver
  • Loading branch information
dgmstuart authored Aug 16, 2024
2 parents 1b7a866 + e386a54 commit ff75566
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/support/system/drivers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# frozen_string_literal: true

# Override Capybara's selenium_chrome_headless driver to disable the chrome search engine selection modal
# If Capybara adds the --disable-search-engine-choice-screen option as a default, we can delete this override.
# This is mostly a copy of the definition from the Capybara source:
Capybara.register_driver :selenium_chrome_headless do |app|
version = Capybara::Selenium::Driver.load_selenium
options_key = Capybara::Selenium::Driver::CAPS_VERSION.satisfied_by?(version) ? :capabilities : :options
browser_options = Selenium::WebDriver::Chrome::Options.new.tap do |opts|
opts.add_argument("--headless=new")
opts.add_argument("--disable-gpu") if Gem.win_platform?
opts.add_argument("--disable-site-isolation-trials")
opts.add_argument("--disable-search-engine-choice-screen")
end

Capybara::Selenium::Driver.new(app, **{ :browser => :chrome, options_key => browser_options })
end

module System
module Drivers
RSpec.configure do |config|
Expand Down

0 comments on commit ff75566

Please sign in to comment.