I’m trying to run browser testing on CircleCi using TestCafe. I have followed this documentation. It is able to successfully download the image though because the spin environment is passed.
I am facing problem in the next step (Container circleci/node:11.6.0-browsers) which throws an error :
$ _XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.
Job was canceled
And later on the UI test step throws this error:
$ testcafe chrome:headless uitests/tests/* -r xunit:/tmp/test-results/res.xml -e
ERROR Was unable to open the browser "chrome:headless" due to error.
Error: Unable to run the browser. The browser path or command template is not specified.
at checkBrowserPath$ (/rp-web/node_modules/testcafe-browser-tools/lib/api/open.js:47:23)
at tryCatch (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:72:40)
at Generator.invoke [as _invoke] (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:334:22)
at Generator.prototype.(anonymous function) [as next] (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:105:21)
at tryCatch (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:72:40)
at invoke (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:146:20)
at /rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:191:11
at new Promise (<anonymous>)
at new F (/rp-web/node_modules/core-js/library/modules/$.export.js:30:36)
at callInvokeWithMethodAndArg (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:190:16)
Type "testcafe -h" for help.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code 1
Also, tried the run command with no sandbox but got the same error: testcafe chrome:headless uitests/tests/* -r xunit:/tmp/test-results/res.xml -e --no-sandbox
Can anyone help with this on how to fix this?
I don’t have a ready answer for you, other than setting up headless browsers in any CI system can be a royal pain. I would recommend using the SSH option so you can tinker, rather than going through the laborious tweak-commit-push-rebuild cycle for every item to try.
Personally, I do all my headless testing in Docker† - it lets me get it working locally, and then it Just Works remotely. However the project for which I have done that on CircleCI used PhantomJS, which is now very dead. One day I will get that working on Chrome Driver or Selenium. However, at least it demonstrates to me that headless browser testing is very possible.
@halfer - hey I tried it with Jenkins which I believe should be much straightforward but still I’m unable to launch any browsers via Jenkins. This is the error I got:
`+ testcafe chrome uitests/tests/peopletest.js -r xunit:res.xml -e .
Using locally installed version of TestCafe.
Error: Unable to run the browser. The file at /Applications/Google Chrome.app does not exist or is not executable.
at Object.callee$0$0$ (/Users/Shared/Jenkins/Home/workspace/RpWeb/node_modules/testcafe-browser-tools/lib/api/open.js:137:23)
at tryCatch (/Users/Shared/Jenkins/Home/workspace/RpWeb/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:72:40)
at Generator.invoke [as _invoke] (/Users/Shared/Jenkins/Home/workspace/RpWeb/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:334:22)
at Generator.prototype.(anonymous function) [as throw] (/Users/Shared/Jenkins/Home/workspace/RpWeb/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:105:21)
at tryCatch (/Users/Shared/Jenkins/Home/workspace/RpWeb/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:72:40)
at invoke (/Users/Shared/Jenkins/Home/workspace/RpWeb/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:146:20)
at /Users/Shared/Jenkins/Home/workspace/RpWeb/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:156:13
Build step 'Execute shell' marked build as failure
Recording test results
Finished: FAILURE`