Skip to content

Commit

Permalink
Disable search engine popup in system specs
Browse files Browse the repository at this point in the history
Since Chrome 128 there is a Search Engine selection
popup even in headless mode that needs to be accepted.
This leads to Capybara Element not found exceptions during
system specs.

Refs: SeleniumHQ/selenium#14438
  • Loading branch information
tvdeyen committed Aug 27, 2024
1 parent 96aa506 commit 57f977a
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions templates/spec/support/solidus_starter_frontend/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@

Capybara.default_max_wait_time = 10

Capybara.register_driver :selenium_chrome_headless_docker_friendly do |app|
browser_options = ::Selenium::WebDriver::Chrome::Options.new
browser_options.args << '--headless'
browser_options.args << '--disable-gpu'
browser_options.args << '--disable-search-engine-choice-screen'
# Sandbox cannot be used inside unprivileged Docker container
browser_options.args << '--no-sandbox'
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end

RSpec.configure do |config|
config.before(:each, type: :system) do
driven_by((ENV['CAPYBARA_DRIVER'] || :rack_test).to_sym)
end

config.before(:each, type: :system, js: true) do |example|
screen_size = example.metadata[:screen_size] || [1800, 1400]
driven_by :selenium, using: :headless_chrome, screen_size: screen_size
driven_by :selenium_chrome_headless_docker_friendly, screen_size: screen_size
end
end

Capybara.register_driver :selenium_chrome_headless_docker_friendly do |app|
browser_options = ::Selenium::WebDriver::Chrome::Options.new
browser_options.args << '--headless'
browser_options.args << '--disable-gpu'
# Sandbox cannot be used inside unprivileged Docker container
browser_options.args << '--no-sandbox'
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end

0 comments on commit 57f977a

Please sign in to comment.