Skip to content

Commit

Permalink
Upgrade selenium-webdriver and selenium-devtools
Browse files Browse the repository at this point in the history
Context for changes:

- https://www.selenium.dev/blog/2023/headless-is-going-away/
- SeleniumHQ/selenium#12417

We must use `--headless` instead of `--headless=new` because the latter causes chromedriver to crash when running within Docker (for some reason 🤷)
  • Loading branch information
robinjam committed Oct 12, 2023
1 parent 106e22d commit f379733
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ GEM
rspec-support (3.12.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
selenium-devtools (0.117.0)
selenium-devtools (0.118.0)
selenium-webdriver (~> 4.2)
selenium-webdriver (4.10.0)
selenium-webdriver (4.14.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
Expand All @@ -376,7 +376,7 @@ GEM
unf_ext
unf_ext (0.0.7.7)
webrick (1.8.1)
websocket (1.2.9)
websocket (1.2.10)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.11)
Expand Down
24 changes: 10 additions & 14 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,31 @@
GovukError.configure

Capybara.register_driver :headless_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
acceptInsecureCerts: ENV.key?("CHROME_ACCEPT_INSECURE_CERTS"),
'goog:loggingPrefs': {
browser: "ALL",
performance: "ALL",
},
)

options = Selenium::WebDriver::Chrome::Options.new
options.headless!
options.add_argument("--headless")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-extensions")
options.add_argument("--disable-gpu")
options.add_argument("--disable-web-security")
options.add_argument("--disable-xss-auditor")
options.add_argument("--user-agent='Smokey Test / Ruby'")
options.add_argument("--no-sandbox") if ENV.key?("NO_SANDBOX")
options.add_argument("--ignore-certificate-errors") if ENV.key?("CHROME_ACCEPT_INSECURE_CERTS")
options.add_option(
"goog:loggingPrefs", { performance: "ALL", browser: "ALL" }
)

service = Selenium::WebDriver::Service.chrome(
args: {
verbose: ENV.key?("CHROMEDRIVER_VERBOSE"),
log_path: ENV.fetch("CHROMEDRIVER_LOG_FILE", "/tmp/chromedriver.log"),
},
args: [
("--verbose" if ENV.key?("CHROMEDRIVER_VERBOSE")),
"--log-path=#{ENV.fetch("CHROMEDRIVER_LOG_FILE", "/tmp/chromedriver.log")}",
].compact,
)

Capybara::Selenium::Driver.new(
app,
browser: :chrome,
capabilities: [capabilities, options],
options:,
service: service,
)
end
Expand Down

0 comments on commit f379733

Please sign in to comment.