Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cypress open/run with specific browser version

I would like to open/run a cypress test with a specific Chrome browser version, I found it is possible to force to chrome with --browser chrome or even with beta with --browser chrome:beta but did not found how to run with a specific version, like for instance --browser chrome:94.

Anybody knows if it is possible ? And if yes, how to do it ?

Edit: as mention in an answer there is the possibility to use --browser /path/to/browser but what I want, if possible of course, is something automatic that does not need an installation of specific browser version before run.

Thanks

like image 294
gluttony Avatar asked Oct 24 '25 17:10

gluttony


2 Answers

It doesn't seem possible to install multiple versions of chrome (apart from chrome:beta and chrome:canary). chrome:stable automatically updates itself on the machine.

In any case you want to do it without installing, Docker is one way to go.

There's a range of images here

cypress/browsers:node14.16.0-chrome89-ff86  
cypress/browsers:node14.17.0-chrome91-ff89  
cypress/browsers:node16.5.0-chrome94-ff93       
cypress/browsers:node16.5.0-chrome97-ff96   
cypress/browsers:node16.13.0-chrome95-ff94  

Be aware that Cypress and Node versions that are compatible with different chrome versions, as indicated here

cypress/included:8.5.0  cypress/browsers:node14.17.0-chrome91-ff89
cypress/included:8.6.0  cypress/browsers:node14.17.0-chrome91-ff89
cypress/included:8.7.0  cypress/browsers:node14.17.0-chrome91-ff89
cypress/included:9.0.0  cypress/browsers:node16.5.0-chrome94-ff93
cypress/included:9.1.0  cypress/browsers:node16.5.0-chrome94-ff93
cypress/included:9.1.1  cypress/browsers:node16.5.0-chrome94-ff93
cypress/included:9.2.0  cypress/browsers:node16.5.0-chrome94-ff93
cypress/included:9.2.1  cypress/browsers:node16.5.0-chrome94-ff93
cypress/included:9.3.0  cypress/browsers:node16.5.0-chrome94-ff93
cypress/included:9.3.1  cypress/browsers:node16.5.0-chrome94-ff93
cypress/included:9.4.1  cypress/browsers:node16.5.0-chrome94-ff93

So if you try to run [email protected] with chrome@91 you may get unexpected errors.

like image 113
Fody Avatar answered Oct 27 '25 14:10

Fody


You can actually do that by passing the path of old browser installed on your system as mentioned in the cypress docs

cypress run --browser /usr/bin/chromium

cypress open --browser /usr/bin/chromium

You can also create multiple commands under your package.json like:

  "scripts": {
    "chrome:95": "cypress run --browser path to chrome 95",
    "chrome:96": "cypress run --browser path to chrome 96",
    "chrome:97": "cypress run --browser path to chrome 97"
  }

Then directly run your tests like:

npm run chrome:95
like image 29
Alapan Das Avatar answered Oct 27 '25 14:10

Alapan Das