Use Chrome for Testing instead of "official" Chrome
As has been discussed and documented here and here, official Chrome builds no longer support loading extensions.
It would probably make sense to update the docker images to use Chrome for Testing rather than "official" Chrome, as recommended by Google. Otherwise, people who want to test browser extensions on chromium-based browsers only have Edge as an option.
@tylerccarson
Thank you for your suggestion and for mentioning the --load-extension flag restrictions in Chrome 137 and above.
Current options
As far as immediate options are concerned, Chrome for Testing is already usable in Cypress Docker images. You can follow the README description in examples/chrome-for-testing on how to build a custom Cypress Docker image with Chrome for Testing. This example is also tested in GitHub Actions.
You can find a reference to this through the [email protected] changelog
- Chrome-branded browsers (e.g., standard Chrome) version 137 and above no longer support extension loading via this API, due to the removal of the
--load-extensionflag by Chrome. We recommend using Chrome for Testing or Chromium instead. See Cypress Docker image examples for Chrome for Testing and Chromium.
Enhancement options
I have added a sub-issue https://github.com/cypress-io/cypress-docker-images/issues/1367 to add Chrome for Testing to the factory build process.
This would be a prerequisite to being able to select which type of Chrome browser is built into off-the-shelf cypress/browsers and cypress/included images.
A decision would then need to be made about which browser should be shipped. Changing from Chrome to Chrome for Testing would be a breaking change that would need to be carefully considered.
At this time it would seem that only a small proportion of Cypress users are affected by the --load-extension flag change in Chrome. See also comment in https://github.com/cypress-io/cypress/issues/31690#issuecomment-2883801636 from the Cypress.io team. Users who would like the default to be changed are invited to up-vote this issue and add any additional specific reasons for the preference as comments to the issue.
Thank you @MikeMcC399 for your feedback on this request.
I completely missed the references to the Docker image example for Chrome for Testing in the changelog, good to know this is possible today.
That said, my target environment is Github actions, so my understanding is I'd need to maintain my own custom docker image in a registry for Github actions to pull and use. It would be much more preferable if is were possible just continue using the latest cypress/browsers image, which automatically updates this pinned browser versions, than having to maintain a registry myself.
I do understand this --load-extension deprecation only affects a portion of Cypress users, so I'm hoping others can chime in and request this change as well.
I also wonder, even if the specific limitation I brought up only affects the small percentage of users who test browser extensions with Cypress, what are the downsides to switching to using Chrome for Testing for all users instead of "official" Chrome? It appears Google builds and publishes it for specifically this purpose.
@tylerccarson
If you are using GitHub Actions, you may consider running directly in a GitHub Linux runner image without using a Docker image. If you use the action browser-actions/setup-chrome you can select specific Chrome for Testing versions for installation. In this case you would not have to deal with custom Docker images.
Changing from "Chrome" to "Chrome for Testing" as a default would be a breaking change simply because the browsers are launched under their respective names chrome and chrome-for-testing (see https://docs.cypress.io/app/references/launching-browsers). This is apart from any other differences between the two browser variations. In any case it introduces a complication that other browsers don't have.
- assessment added to https://github.com/cypress-io/cypress-docker-images/issues/1367#issuecomment-2955699965
cypress/factory:5.11.0 has introduced the capability of building a custom Docker image based on the CHROME_FOR_TESTING_VERSION.
This does not implement the suggestion in the issue to replace Chrome with Chrome for Testing, however it does give greater flexibility, also for any future strategic decision that might favor Chrome for Testing over Chrome.
so I'm hoping others can chime in and request this change as well.
Heads up I am definitely no expert in this topic, but I would definitely support the request. Especially considering the beta pupeteer extension for cypress. We used both the pupeteer extension and a docker image based on the cypress/browser image and just beeing able to add chrome-for-testing would be greatly appreciated
@GenFlogi
Heads up I am definitely no expert in this topic, but I would definitely support the request. Especially considering the beta pupeteer extension for cypress. We used both the pupeteer extension and a docker image based on the cypress/browser image and just beeing able to add chrome-for-testing would be greatly appreciated
Thanks for your input! Please upvote (like button) the original post to show your desire to have Chrome for Testing as default Chrome browser in Cypress Docker images. (This is in addition to it being available as an option which is already the case today).
The @cypress/puppeteer README states:
Chrome-branded browsers (e.g., standard Chrome) are not supported in version 137+ due to Chrome's removal of the --load-extension flag. We recommend using Electron, Chrome for Testing or Chromium instead. See Cypress Docker image examples for Chrome for Testing and Chromium. Note this change only applies to headed applications such as cypress open or cypress run --headed. The plugin will work as expected in cypress run mode in any version of Chrome.
so according to this description, it should be possible to use @cypress/puppeteer directly with cypress/browsers, if you are using cypress run mode, without needing "Chrome for Testing".
If you are using GitHub Actions, you may consider running directly in a GitHub Linux runner image without using a Docker image. If you use the action browser-actions/setup-chrome you can select specific Chrome for Testing versions for installation. In this case you would not have to deal with custom Docker images.
Thank you @MikeMcC399 for the recommendation. This alternative approach appears to be working for me. Feel free to close this issue then if you don't see Cypress switch to using Chrome for Testing by default.
@tylerccarson
Thank you @MikeMcC399 for the recommendation. This alternative approach appears to be working for me. Feel free to close this issue then if you don't see Cypress switch to using Chrome for Testing by default.
Thank you for your feedback! I will go ahead and close this issue now as you suggest. The alternatives mentioned in the thread are:
- Following examples/chrome-for-testing using Chrome for Testing through @puppeteer/browsers
- Using the parameter CHROME_FOR_TESTING_VERSION in the Cypress Docker image factory build process
Without using a Docker image in GitHub Actions: