Skip to content

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

Open
dan-jensen wants to merge 2 commits intohashrocket:masterfrom
dan-jensen:update-chrome-headless-option-syntax
Open

Fix NoMethodError with headless Chrome 119+ (and deprecation warning with headless Chrome)#53
dan-jensen wants to merge 2 commits intohashrocket:masterfrom
dan-jensen:update-chrome-headless-option-syntax

Conversation

@dan-jensen
Copy link
Contributor

@dan-jensen dan-jensen commented Jun 19, 2023

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

In selenium-webdriver 4.8.0, the `headless!` method was deprecated and
now raises a warning.

This updates to use syntax that does not raise a warning, but is still
friendly to versions of Chrome before v109.
@dan-jensen
Copy link
Contributor Author

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

Chrome now allows the --headless option to be specified with a value.
This applies the "new" value so the latest version will be used.
@dan-jensen dan-jensen changed the title Fix deprecation warning with headless Chrome Fix NoMethodError with headless Chrome 119+ (and deprecation warning with headless Chrome) Dec 11, 2023
@dan-jensen
Copy link
Contributor Author

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

@ryanb ryanb mentioned this pull request Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant