Remove the 'Choose Your Search Engine' Dialog in Capybara
Google recently added a dialog to let users select their search engine. Ordinarily you choose your preferred search engine and get on with life, but this doesn't appear to be the case when using Chrome for automation, such as through Capybara; everything is fine if running in headless mode — as evidenced by any automated screenshots — but if you flip headless off, as I'm like to do to quickly debug issues, all I'm able to see is this dialog. Every time.

After a little searching, it turns out there's a flag to disable this dialog: --disable-search-engine-promos
. But how do we set this in Capybara? You'll need to register your own driver and pass it into browser options. For instance, I am using the following:
Capybara.register_driver(:better_cuprite) do |app|
Capybara::Cuprite::Driver.new(
app,
window_size: [1200, 800],
browser_options: {
:"disable-search-engine-choice-screen" => nil
},
process_timeout: 10,
inspector: true,
headless: !ENV["HEADLESS"].in?(%w[n 0 no false])
)
end
Capybara.default_driver = Capybara.javascript_driver = :better_cuprite