capybara-webmock icon indicating copy to clipboard operation
capybara-webmock copied to clipboard

Fix NoMethodError with headless Chrome 119+ (and deprecation warning with headless Chrome)

Open dan-jensen opened this issue 1 year ago • 2 comments

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. Use Options#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.)

dan-jensen avatar Jun 19 '23 21:06 dan-jensen

@dillonhafer just want to draw attention to this PR from June. Hopefully an easy merge.

dan-jensen avatar Oct 16 '23 01:10 dan-jensen

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).

dan-jensen avatar Dec 11 '23 18:12 dan-jensen