Modify the GitLab recipe to use Headless Chromium
What is your Scenario?
We run our tests on gitlabci using the official docker image testcafe/testcafe:1.16.0 and all is fine. Tests are executed behind the proxy. We tried to switch to a more fresh version 1.18.3 (changed only docker tag) but this resulted in the pipeline failure, tests are not executed and we see the next error:
ERROR Cannot establish one or more browser connections.
1 of 1 browser connections have not been established:
- chromium --start-maximized --incognito
Hints:
- Increase the value of the "browserInitTimeout" option if it is too low (currently: 2 minutes for local browsers and 6 minutes for remote browsers). This option determines how long TestCafe waits for browsers to be ready.
- The error can also be caused by network issues or remote device failure. Make sure that your network connection is stable and you can reach the remote device.```
- >
/opt/testcafe/docker/testcafe-docker.sh "chromium --start-maximized --incognito"
-c 1
e2e/tests/*.test.ts
--skip-js-errors --color
--reporter spec,xunit:e2e/tests/reports/index.xml,html:e2e/tests/reports/index.html
--video e2e/tests/reports/video
--video-options singleFile=false,failedOnly=true,pathPattern='${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}'.mp4
-s takeOnFails=true,path=e2e/tests/reports/screenshots,fullPage=true,pathPattern='${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}'.png
--page-load-timeout 90000
--assertion-timeout 60000
--proxy $CODE_PROXY_HOST:$CODE_PROXY_PORT
--page-request-timeout 60000
-q attemptLimit=2,successThreshold=1
### What is the Current behavior?
Tests did not run
### What is the Expected behavior?
Tests are executed
### What is your public website URL? (or attach your complete example)
----
### What is your TestCafe test code?
any
### Your complete configuration file
no file
### Your complete test report
_No response_
### Screenshots
_No response_
### Steps to Reproduce
1. Run any test in docker v1.18.3
### TestCafe version
1.18.3
### Node.js version
-
### Command-line arguments
- > /opt/testcafe/docker/testcafe-docker.sh "chromium --start-maximized --incognito" -c 1 e2e/tests/*.test.ts --skip-js-errors --color --reporter spec,xunit:e2e/tests/reports/index.xml,html:e2e/tests/reports/index.html --video e2e/tests/reports/video --video-options singleFile=false,failedOnly=true,pathPattern='${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}'.mp4 -s takeOnFails=true,path=e2e/tests/reports/screenshots,fullPage=true,pathPattern='${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}'.png --page-load-timeout 90000 --assertion-timeout 60000 --proxy $CODE_PROXY_HOST:$CODE_PROXY_PORT --page-request-timeout 60000 -q attemptLimit=2,successThreshold=1
### Browser name(s) and version(s)
chromium
### Platform(s) and version(s)
-
### Other
-
Unfortunately, I couldn't reproduce the issue on my side. Could you please share your project or, at least, your gitlab config file so that we can examine it and determine the cause of the issue?
Hi @dositec
I can not share my project but it is quite standard I would say.
gitlab.ci is similar to the documentation https://testcafe.io/documentation/402816/guides/continuous-integration/gitlab
e2e_tests:
image:
name: testcafe/testcafe:1.18.3
entrypoint: ["/bin/sh", "-c"]
script:
- >
/opt/testcafe/docker/testcafe-docker.sh "chromium --start-maximized --incognito"
-c 1
e2e/tests/*.test.ts
--skip-js-errors --color
--reporter spec,xunit:e2e/tests/reports/index.xml,html:e2e/tests/reports/index.html
--video e2e/tests/reports/video
--video-options singleFile=false,failedOnly=true,pathPattern='${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}'.mp4
-s takeOnFails=true,path=e2e/tests/reports/screenshots,fullPage=true,pathPattern='${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}'.png
--page-load-timeout 90000
--assertion-timeout 60000
--proxy $CODE_PROXY_HOST:$CODE_PROXY_PORT
--page-request-timeout 60000
-q attemptLimit=2,successThreshold=1
and these tests run thru proxy.
I could not reproduce the problem with the settings on my side. You can try to find its cause on your own. Add the disablehttp2 argument to the Jobs section of your .yml GitLab CI configuration file. Then, try to reproduce the problem and share your results with us.
nothing has changed with that flag

Seems it is chromium related issue. I've tried to run tests in firefox with the same settings and it works fine.

In chromium:headless it also works fine.
I'm happy to hear that you've solved the problem. Could you please create a simple public project on GitLab where the problem is reproduced and share a project link so that we can research the problem and fix it?
Here it is: https://gitlab.com/AM1988/testacfe-ci-setup/-/tree/docker_testcafe_1.18.3 (branch -> docker_testcafe_1.18.3)
Example of failed pipeline: https://gitlab.com/AM1988/testacfe-ci-setup/-/jobs/2093946120
$ /opt/testcafe/docker/testcafe-docker.sh "chromium --start-maximized --incognito" -c 1 e2e/tests/*.test.ts --skip-js-errors --color --page-load-timeout 90000 --assertion-timeout 60000 --page-request-timeout 60000 -q attemptLimit=2,successThreshold=1
ERROR Cannot establish one or more browser connections.
1 of 1 browser connections have not been established:
- chromium --start-maximized --incognito
Hints:
- Increase the value of the "browserInitTimeout" option if it is too low (currently: 2 minutes for local browsers and 6 minutes for remote browsers). This option determines how long TestCafe waits for browsers to be ready.
- The error can also be caused by network issues or remote device failure. Make sure that your network connection is stable and you can reach the remote device.
We have also observed this issue quite often on latest testcafe docker image for chromium:headless For us the issue is seen intermittently i.e. not reproducible for every run, but a bunch of jobs fail over a period of time.
I ran into the same problem today. Yesterday we switched our Kubernetes NodePools from Container-Optimized OS with Docker (cos) to Container-Optimized OS with containerd (cos_containerd) and the error has been occurring since then.
This solved the issue for us: https://testcafe.io/documentation/402838/guides/advanced-guides/use-testcafe-docker-image#troubleshooting
I've tried with "chromium --no-sandbox --disable-dev-shm-usage" but that does not help, still getting the same error.
I have this problem too, but unfortunately I can't share it, --no-sandbox --disable-dev-shm-usage do not help, forfox is ok,but not stabilization
Not sure if it helps in resolving this problem, I had reported very similar issue couple of months back here.
Hello @AM1988, thank for the provided links:
Here it is: https://gitlab.com/AM1988/testacfe-ci-setup/-/tree/docker_testcafe_1.18.3 (branch -> docker_testcafe_1.18.3) Example of failed pipeline: https://gitlab.com/AM1988/testacfe-ci-setup/-/jobs/2093946120
Unfortunately, I can't open the links. I think this is related to the permission level of the project. I am currently getting a "404 Page Not Found" page. Could you please give public permissions to the project?
@dositec my fault, fixed. Could you please check once again?
@AM1988 Thank you for the answer. Currently, I have access to your project, but I don't have access to your CI/CD; we need it to reproduce the problem (I have access to the pipelines but I don't have access to the "Run" button). Could you please give us access to your CI/CD? You can send the credentials to our email - [email protected]. We will keep this information private and will remove the credential when we resolve this problem.
@dositec I've given you a 'Developer' role in that project. So you should be able to run the pipeline now. I believe you can also simply fork the project and try it within your own account.
I will not share my creds )
@AM1988 Thank you for the clarification and help. We reproduced the behavior, but we don't think that it's a bug. Could you please to try using "chromium:headless" instead of "chromium" in your .yaml file to avoid the error message? We will correct our documentation to point out that the correct way is to use "chromium:headless" in the pipeline file.
yup, chromium:headless does the job as I said in the https://github.com/DevExpress/testcafe/issues/6865#issuecomment-1038933460
The documentation has been updated. It may take a while for the website to reflect these changes.