diff --git a/Gemfile b/Gemfile index 103ae94f..f6ee3046 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gem "nokogiri", "~> 1" gem "plek", "~> 4" gem "rest-client", "~> 2" gem "rspec", "~> 3" -gem "selenium-webdriver", "~> 3" +gem "selenium-webdriver", "~> 4" group :development do gem "pry-byebug", "~> 3" diff --git a/Gemfile.lock b/Gemfile.lock index 0ccd4fd6..0c19f634 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,8 +19,7 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - childprocess (0.9.0) - ffi (~> 1.0, >= 1.0.11) + childprocess (4.1.0) coderay (1.1.2) concurrent-ruby (1.1.8) cucumber (5.3.0) @@ -57,7 +56,7 @@ GEM diff-lcs (1.4.4) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - ffi (1.14.2) + ffi (1.15.5) http-accept (1.7.0) http-cookie (1.0.3) domain_name (~> 0.5) @@ -99,6 +98,7 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) + rexml (3.2.5) rspec (3.11.0) rspec-core (~> 3.11.0) rspec-expectations (~> 3.11.0) @@ -112,9 +112,10 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubyzip (2.3.0) - selenium-webdriver (3.142.7) - childprocess (>= 0.5, < 4.0) + rubyzip (2.3.2) + selenium-webdriver (4.1.0) + childprocess (>= 0.5, < 5.0) + rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2) sys-uname (1.2.2) ffi (~> 1.1) @@ -141,7 +142,7 @@ DEPENDENCIES pry-byebug (~> 3) rest-client (~> 2) rspec (~> 3) - selenium-webdriver (~> 3) + selenium-webdriver (~> 4) BUNDLED WITH 2.1.4 diff --git a/features/step_definitions/datagovuk_steps.rb b/features/step_definitions/datagovuk_steps.rb index 3142f974..f91d390a 100644 --- a/features/step_definitions/datagovuk_steps.rb +++ b/features/step_definitions/datagovuk_steps.rb @@ -30,7 +30,7 @@ end And /^I don't get any s3 CSP errors$/ do - messages = Capybara.current_session.driver.browser.manage.logs.get(:browser).map(&:message) + messages = Capybara.current_session.driver.browser.logs.get(:browser).map(&:message) regex = /Refused to connect to 'https:\/\/s3.*because it violates the following Content Security Policy directive: "connect-src/ messages.each do |message| expect(message).to_not match(regex) diff --git a/features/support/browser.rb b/features/support/browser.rb index bd89c770..52c93654 100644 --- a/features/support/browser.rb +++ b/features/support/browser.rb @@ -55,7 +55,7 @@ def browser_has_request_containing # # https://github.com/dbalatero/capybara-chromedriver-logger/blob/e972c9865ac1955529649566704d5878205f909c/lib/capybara/chromedriver/logger/collector.rb#L49 @logs += Capybara.current_session.driver - .browser.manage.logs.get(:performance) + .browser.logs.get(:performance) .map { |log| JSON.load(log.message)['message'] } # The "messages" we're interested in look like this: diff --git a/features/support/env.rb b/features/support/env.rb index 89000b78..3750201d 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -21,7 +21,6 @@ # Set up basic URLs Capybara.app_host = ENV["GOVUK_WEBSITE_ROOT"] -# Use Chrome in headless mode Capybara.register_driver :headless_chrome do |app| capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( acceptInsecureCerts: true, @@ -38,12 +37,12 @@ options.add_argument("--user-agent=Smokey\ Test\ \/\ Ruby") options.add_argument("--no-sandbox") if ENV.key?("NO_SANDBOX") - Capybara::Selenium::Driver.new( - app, + browser_options = { browser: :chrome, - options: options, - desired_capabilities: capabilities - ) + capabilities: [capabilities, options] + } + + Capybara::Selenium::Driver.new(app, browser_options) end Capybara.default_driver = :headless_chrome diff --git a/features/support/hooks.rb b/features/support/hooks.rb index 04a5a66d..67acade2 100644 --- a/features/support/hooks.rb +++ b/features/support/hooks.rb @@ -34,7 +34,6 @@ def browser_logs(type) Capybara .current_session .driver.browser - .manage .logs .get(type) end