Cypress open/run with specific browser version - browser

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

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 Cypress#9.4.1 with chrome#91 you may get unexpected errors.

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

Related

ChromeNotInstalledError while using chrome-launcher npm package

I am using chrome-launcher for running lighthouse programmatically. It works fine locally but when I run it on azure I am getting an error.
On this statement const chrome = await chromeLauncher.launch({chromeFlags: ['--headless']}); I am getting the following error:
ChromeNotInstalledErrorat new LauncherError (C:\home\site\wwwroot\node_modules\chrome-launcher\dist\utils.js:37:22)at new ChromeNotInstalledError (C:\home\site\wwwroot\node_modules\chrome-launcher\dist\utils.js:68:9){message: 'No Chrome installations found.',code: 'ERR_LAUNCHER_NOT_INSTALLED'}
How can I solve this?
You need to install Chrome on the Azure Function app somehow.
One way to do this is by using an npm dependency that installs Chrome as part of its install process. Examples of this are puppeteer and playwright. Although then you end up with some unnecessary dependencies.
You could also have a startup script or something that installs Chrome before running chrome-launcher/lighthouse. You'll need to tell crome-launcher where Chrome is installed if it's not a standard place using chromePath options or CHROME_PATH environment variable link.
You also have to ensure you do a Remote Build for the Function app.
You will also run into this error, which has a possible workaround: https://github.com/GoogleChrome/chrome-launcher/issues/188
Overall it's not easy. I actually ended up moving my workflow to GitHub Actions instead as Chrome is already installed on their runner images.
See:
https://anthonychu.ca/post/azure-functions-headless-chromium-puppeteer-playwright/

testcafe execution via intelliJ run action

I have my testcafe test which is running well via terminal with
testcafe chrome jira-web-front\src\test\script\testcafe
I would like to be able to run it inside intelliJ js editor by clicking on the play button:
When I execute my test by clicking on the green play button I have:
I have some jest tests also in my project.
I tried to install intelliJ testcafe plugin but it didn't help.
Any idea about this?
Thanks
The logic currently used by JavaScript support plugin for detecting what test runner is available for a given test file is based on dependencies declarations in package.json nearest to this file: it looks for known test runners listed there and tries to run the most suitable one. As IDEA
doesn't provide any support for TestCafe (https://youtrack.jetbrains.com/issue/WEB-30315), you can't expect it to run TestCafe from a gutter; it runs your tests with jest because you have it in your dependencies list.
To run test using the run configuration provided by testcafe plugin, you need right-clicking the test in editor:
This plugin doesn't support running tests from gutter, neither it supports debugging.
Note that you can use VS Code recipes to debug TestCafe in IDEA. Namely, you need Node.js Run configuration like the following:
where JavaScript file: is set to a path to your locally installed testcafe module, e.g. node_modules\testcafe\bin\testcafe.js, and Application parameters: are testcafe cli args, like
chrome myTestFile.js

Gitlab's autodevops: Herokuish buildpack test can't find chrome binary

Gitlab's "autodevops" feature comes with a default step in the 'test' stage called 'test', which uses herokuish to run my rails app's rspec suite. Unfortunately, it fails on my system/integration specs that requires the chrome browser to be installed.
I've tried adding herokuish buildpack install https://github.com/heroku/heroku-buildpack-google-chrome before herokuish buildpack test but it still can't find the Chrome binary. The error looks like the following:
Failure/Error:
visit root_path
Webdrivers::VersionError:
Failed to find Chrome binary or its version.
Any help is appreciated.
Probably a bit too late but here's a working solution as of September 2020.
https://github.com/guzmanoj/herokuish-install-chrome
The script will resolve the chrome dependencies so that CHROME_BIN will be defined in the host OS.

Angular cli, overwrite the command that gets run by 'ng e2e'?

I'm trying run Angular's e2e tests against an instance of the application ON A DIFFERENT SERVER than my local machine.
So to be clear, I'm not testing my local code.
I just need to run protractor without the angular build steps because it's a waste of time since the code I'm testing is on another server. Unfortunately, the angular.json file throws an error if i excessively modify/remove the following line:
"builder": "#angular-devkit/build-angular:protractor",
I already have a solution for this, but it's long winded and I'd like to be able to not change how my teammates are running tests from their shells:
node node_modules/protractor/bin/protractor e2e/protractor.conf.js
I have two thoughts:
Write npm script which runs this command (what i'll likely end up doing)
Find out how to overwrite what ng e2e does. If I can run the more complicated command here, it'll save productivity and feedback time.
I'm on Angular V7.
Is overwriting ng e2e so that it executes node node_modules/protractor/bin/protractor e2e/protractor.conf.js instead possible?
Yup. I would do #1. That makes sense to update your package.json
"scripts": {
"protractor": "protractor e2e/protractor.conf.js"
}
and then just run npm run protractor. The e2e command is also downloading chromedriver, the selenium jar file, and maybe geckodriver? with webdriver-manager. If you want that as a pre-step:
"scripts": {
"protractor": "protractor e2e/protractor.conf.js",
// just download chromedriver and the selenium jar
"preprotractor": "webdriver-manager update --gecko false"
}
It also starts your angular application. If you need to do that, I would just call ng serve and run it in a background process. I hope that helps.

Cucumber Js - How to run the features [Windows]

I'm trying to learn cucumber and so far got a grip on installing nodejs, cucumber, creating package.json, storing features files and steps. But when I'm trying to run using windows command prompt, I'm getting the below shown error.
project structure
features
- example.feature
- step_definitions
- steps.js
- support (nothing here yet)
node_modules (cucumber installed locally)
package.json
I started executing commands from the bin folder to ensure cucumberjs works and it echo'd out the version number 3.1.0
C:\Test Project\node_modules\.bin>cucumberjs -v
and then began to run the feature file
C:\Test Project\node_modules\.bin>cucumberjs "C:\Test Project\features\example.feature"
and it errors here
Note: If i install the cucumber globally then it works, this error happens when I install cucumber locally
Any help pointing out where I'm going wrong will be much appreciated
I haven't figured out what's the reason behind the error but managed to run the features files by adding the following to the project package.json and running cli npm run cucumber
"scripts": {
"cucumber": "cucumberjs ./features"
},

Resources