Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Update to remove deprecation messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
KludgeKML committed May 17, 2022
1 parent 31d44a8 commit bada8ed
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion features/step_definitions/datagovuk_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion features/support/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
29 changes: 17 additions & 12 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,33 @@
Capybara.app_host = ENV["GOVUK_WEBSITE_ROOT"]

# Use Chrome in headless mode

chrome_args = [
"headless",
"disable-gpu",
"disable-xss-auditor",
"--user-agent=Smokey\ Test\ \/\ Ruby"
]
chrome_args << ["no-sandbox"] if ENV.key?("NO_SANDBOX")

Capybara.register_driver :headless_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
acceptInsecureCerts: true,
'goog:chromeOptions': {
args: chrome_args
},
'goog:loggingPrefs': {
browser: "ALL",
performance: "ALL"
},
)

options = Selenium::WebDriver::Chrome::Options.new
options.add_argument("--headless")
options.add_argument("--disable-gpu")
options.add_argument("--disable-xss-auditor")
options.add_argument("--user-agent=Smokey\ Test\ \/\ Ruby")
options.add_argument("--no-sandbox") if ENV.key?("NO_SANDBOX")

Capybara::Selenium::Driver.new(
app,
options = {
browser: :chrome,
options: options,
desired_capabilities: capabilities
)
capabilities: capabilities
}

Capybara::Selenium::Driver.new(app, options)
end

Capybara.default_driver = :headless_chrome
Expand Down
1 change: 0 additions & 1 deletion features/support/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def browser_logs(type)
Capybara
.current_session
.driver.browser
.manage
.logs
.get(type)
end

0 comments on commit bada8ed

Please sign in to comment.