-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rb] Fully support Chrome 120+ old headless mode #13271
Conversation
fa480b3
to
58e58d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR.
Let's leave the test files alone, those get toggled off of the values we pass in, not what comes back from the browser. (also we just aren't going to be running tests with the old headless).
When Chrome's new headless mode was announced, it was mentioned that they intended to remove the old headless mode from the Chrome binary. Some people still want to use the old headless mode, as it's more lightweight, performant, and has fewer dependencies - at the expense of having fewer features. Chrome 120+ has a standalone `chrome-headless-shell` binary to keep the old headless mode working for those who wish to use it. If your Ruby code sets up the Chrome driver with `--headless` (which currently defaults to `old`) or `--headless=old` explicitly, you will lose capabilities such as setting permissions, fetching the logs and using the CDP API. That happens because the new binary has a browser name of `chrome-headless-shell`, instead of `chrome`. That makes it be recognized as something other than Chrome, not setting its capabilities. This commit introduces `chrome-headless-shell` as an alternative Chrome browser name, fixing this issue. Fixes SeleniumHQ#13112
58e58d2
to
4be5859
Compare
@titusfortner I removed the specs changes, amending on the same commit. Thank you for the explanation! |
I'm running into this issue and having trouble with the new headless. Do you know when the next release will be that contains this fix? |
The current plan is to release about as often as Google does https://chromiumdash.appspot.com/schedule |
Thanks. I'm having trouble migrating to For those who may be facing the same issue, you can set the version like this. Selenium::WebDriver::Chrome::Options.new(
args: ["headless=old"],
browser_version: "119",
), |
`./modules/my_page/spec/features/my/my_spent_time_widget_with_a_negative_time_zone_spec.rb` is failing with error `undefined method `execute_cdp' for #<Selenium::WebDriver::Chrome::Driver:0x..fe768862b9701efbc browser=:"chrome-headless-shell">`. The `--headless` flag uses the old headless mode of Chrome. Since version 120, this version's name is "chrome-headless-shell". This name is not properly recognized in selenium-webdriver 4.16.0 and some extensions are not loaded, like the one allowing to use execute_cdp. This will be fixed in next selenium-webdriver with this PR: SeleniumHQ/selenium#13271 In the meantime, using the new headless mode with `--headless=new` fixes the issue.
`./modules/my_page/spec/features/my/my_spent_time_widget_with_a_negative_time_zone_spec.rb` is failing with error `undefined method `execute_cdp' for #<Selenium::WebDriver::Chrome::Driver:0x..fe768862b9701efbc browser=:"chrome-headless-shell">`. The `--headless` flag uses the old headless mode of Chrome. Since version 120, this version's name is "chrome-headless-shell". This name is not properly recognized in selenium-webdriver 4.16.0 and some extensions are not loaded, like the one allowing to use execute_cdp. This will be fixed in next selenium-webdriver with this PR: SeleniumHQ/selenium#13271 In the meantime, using the new headless mode with `--headless=new` fixes the issue.
I think a lot of projects will need to implement this temporary workaround in order to get their CI to pass. @titusfortner |
Using |
@titusfortner a couple questions that might help those migrating to the new headless.
Thanks for your time. |
Probably. It depends on if it was actually a bug in the old headless. :) |
@titusfortner thanks for the reply.
I guess a better check is if it works in non headless chrome but not in new headless chrome. In my case drag & drop isn't working in new headless but it does work in old headless and non headless Chrome. I'll look into it further and file a bug once I've isolated the issue. |
Oh that's interesting. Drag and Drop with HTML 5 draggable / droppable elements hasn't actually ever worked with the drivers as far as I know. (perpetual complaints as you may have guessed). |
It is a temporary workaround in projects that use selenium, because it is only necessary until this commit is released. Just see the linked pull requests
Openproject opf/openproject#14426
They are working around the problem that this pull request fixes. It seems they would have preferred to just update to a selenium-webdriver version that included this fix. If it is the recommendation going forward to add There are probably also a lot of frameworks that need to catch up and add If you release a patch version, everyone can upgrade to |
We're arguing semantics. Encouraging people to use the recommended settings shouldn't include the baggage of the term "workaround," even if it entails "extra work," but I think we each get the other's point here. Google will soon(?) be switching There is code in trunk that for /reasons/ cannot be released, yet, so doing a patch release is no longer an option. The next minor release will be for all languages when Chrome 121 comes out in January. |
Looks like there was some change in headless chrome where some features were removed, including execute_cdp, which we rely on for the tests which exercise the clipboard. There's an old mode which is faster but doesn't have all the features of a real browser, and a new mode which does. SeleniumHQ/selenium#13112 SeleniumHQ/selenium#13271 Maybe a better approach would be to keep the old mode for fast tests which don't need these features and use new mode for tests which do.
3.40 will use the new headless chrome, but it hasn't been merged yet. As far as I can gather there was some change in Chrome where they split headless into two versions: old and new. The old one is used by default, but is missing some features were removed, including execute_cdp, which we rely on for the tests which exercise the clipboard This PR explains it pretty well: SeleniumHQ/selenium#13271 What makes this confusing is that the headless browser is provided by the selenium-webdrivers gem, but driver is specified by Capybara: teamcapybara/capybara@e2f9f6c The result was that we got failures on some environments saying that execute_cdp is not defined - this is presumably due to the Chrome version being updated - independent of the codebase. Note that unfortunately the "new" headless browser is slower, but I think it's probably worth it for keeping the config simple and using a more realistic browser.
For folks who were following this and want to use the old headless mode: this was released this week 🎉 |
Looks like there was some change in headless chrome where some features were removed, including execute_cdp, which we rely on for the tests which exercise the clipboard. There's an old mode which is faster but doesn't have all the features of a real browser, and a new mode which does. SeleniumHQ/selenium#13112 SeleniumHQ/selenium#13271 Maybe a better approach would be to keep the old mode for fast tests which don't need these features and use new mode for tests which do.
Looks like there was some change in headless chrome where some features were removed, including execute_cdp, which we rely on for the tests which exercise the clipboard. There's an old mode which is faster but doesn't have all the features of a real browser, and a new mode which does. SeleniumHQ/selenium#13112 SeleniumHQ/selenium#13271 Maybe a better approach would be to keep the old mode for fast tests which don't need these features and use new mode for tests which do.
Looks like there was some change in headless chrome where some features were removed, including execute_cdp, which we rely on for the tests which exercise the clipboard. There's an old mode which is faster but doesn't have all the features of a real browser, and a new mode which does. SeleniumHQ/selenium#13112 SeleniumHQ/selenium#13271 Maybe a better approach would be to keep the old mode for fast tests which don't need these features and use new mode for tests which do.
Motivation and Context
When Chrome's new headless mode was announced, it was mentioned that they intended to remove the old headless mode from the Chrome binary. Some people still want to use the old headless mode, as it's more lightweight, performant, and has fewer dependencies - at the expense of having fewer features.
Chrome 120+ has a standalone
chrome-headless-shell
binary to keep the old headless mode working for those who wish to use it. If your Ruby code sets up the Chrome driver with--headless
(which currently defaults toold
) or--headless=old
explicitly, you will lose capabilities such as setting permissions, fetching the logs, and using the CDP API.This change is explained on the Chrome for Developers blog: Download old Headless Chrome as chrome-headless-shell
That happens because the new binary has a browser name of
chrome-headless-shell
, instead ofchrome
. That makes it be recognized as something other than Chrome, not setting its capabilities.Description
This commit introduces
chrome-headless-shell
as an alternative Chrome browser name, fixing this issue.Types of changes
Checklist
Fixes #13112