capybara-webmock
capybara-webmock copied to clipboard
Fix NoMethodError with headless Chrome 119+ (and deprecation warning with headless Chrome)
The selenium-webdriver gem's headless!
method was deprecated, it now raises a warning.
This updates to use the recommended syntax. This new syntax is NOT compatible with Chrome versions before v109.
Additional details:
- Example warning: "WARN Selenium [:headless] [DEPRECATION]
Options#headless!
is deprecated. UseOptions#add_argument('--headless=new')
instead." - Origin: selenium-webdriver 4.8.0 included change to "Deprecate #headless! for Chrome and Firefox"
- Resolution:
selenium-webdriver
suggests using...=new
. That syntax is only appropriate for Chrome v109+ (meaning Chrome versions released 2023-01-10 onward). (See the code comment for details.)
@dillonhafer just want to draw attention to this PR from June. Hopefully an easy merge.
I just updated this PR to use --headless=new
.
Originally, this PR implemented the syntax used by Capybara's selenium_chrome_headless
driver (without ...=new
), because that was compatible with Chrome versions before 109. However, as of Chrome 119, that approach isn't viable because it spawns a legacy "chrome-headless-shell" browser instead of the latest "chrome" browser. These two different browsers have different capabilities, and the newer browser is preferable both for the sake of its superior capabilities and for the sake of generally keeping up with the latest advancements (learn more).