1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

seleniumのsystem specでheadless chromeを利用している際, Chrome120に更新されてから通らなくなった原因の解消

Posted at

ruby3.1
rails 7.0
selenium-web-driver 4.16
capybara 3.39.2

結果としては、headless chromeを使う際のオプション名が原因でbrowserNameがchromeとなるはずがchrome-headless-shellになっていた。
chromeはヘッドレスモードが2種類あり、古い方がchrome-headless-shellとなるようだ。
chrome-headless-shellは別で専用のバイナリが公式から用意されていて、そちらをDLして使う事も可能らしい。

修正前

Capybara.register_driver :chrome do |app|
  options = Selenium::WebDriver::Options.chrome
  options.args << '--headless'
  options.args << '--no-sandbox'
  options.args << '--disable-dev-shm-usage'
end

修正後

Capybara.register_driver :chrome do |app|
  options = Selenium::WebDriver::Options.chrome
  options.args << '--headless=new' # 新しいheadless modeを使う
  options.args << '--no-sandbox'
  options.args << '--disable-dev-shm-usage'
end

参考
https://www.selenium.dev/blog/2023/headless-is-going-away/
https://developer.chrome.com/blog/chrome-headless-shell?hl=ja

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?