From 7cae3e641c73d4f6690aef2aae5162960a5baa34 Mon Sep 17 00:00:00 2001 From: Steve Laing Date: Fri, 5 Oct 2018 12:06:32 +0100 Subject: [PATCH 1/2] Add custom chrome driver config --- test/test_helper.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 59cdead96..8a43ac294 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -11,8 +11,19 @@ Dir[Rails.root.join('test/support/*.rb')].each { |f| require f } -Capybara.default_driver = :selenium_chrome_headless -Capybara.javascript_driver = :selenium_chrome_headless +Capybara.register_driver :headless_chrome do |app| + capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( + chromeOptions: { args: %w(headless disable-gpu no-sandbox) } + ) + + Capybara::Selenium::Driver.new( + app, + browser: :chrome, + desired_capabilities: capabilities + ) +end +Capybara.default_driver = :headless_chrome +Capybara.javascript_driver = :headless_chrome GovukAbTesting.configure do |config| config.acceptance_test_framework = :active_support From c4d03d5de86579338827af31da7c6ea85d122365 Mon Sep 17 00:00:00 2001 From: Steve Laing Date: Fri, 5 Oct 2018 12:12:32 +0100 Subject: [PATCH 2/2] Increase default Selenium driver timeout It's common for the first net http request to fail, supposedly due to the length of time asset compilation can take. Increase the default timeout to 90 seconds. --- test/test_helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 8a43ac294..2abbc2f16 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -15,13 +15,17 @@ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( chromeOptions: { args: %w(headless disable-gpu no-sandbox) } ) + client = Selenium::WebDriver::Remote::Http::Default.new + client.timeout = 90 # Asset compilation can result in a timeout on the first request hence the increase. Capybara::Selenium::Driver.new( app, browser: :chrome, - desired_capabilities: capabilities + desired_capabilities: capabilities, + http_client: client ) end + Capybara.default_driver = :headless_chrome Capybara.javascript_driver = :headless_chrome