2

I have all my setup on AWS EC2 and I'm using Jenkins for my test jobs. It seems pretty difficult to install chrome in AWS so that easiest option for me is to get the docker chrome for my tests. I'm using this docker image and running the container using the command docker run -p 3000:3000 -d browserless/chrome.

As per the TestCafe documentation, I'm using the remote browser connection to trigger my tests. I'm not getting any error but looks like the connection hangs and here is the output:

+ node awsrunner.js
http://localhost:1337/browser/connect/6M9cgTu
<<spinning wheel here>>

I'm not sure how do I establish a connection with the headless chrome through TestCafe so that I can run my tests.

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Psdet
  • 659
  • 9
  • 24

1 Answers1

2

I suggest you use the testcafe-browser-provider-browserless plugin instead.

As for the remote browser connection, it provides an URL (http://localhost:1337/browser/connect/6M9cgTu in your case) that you should visit from a remote browser. Once the browser connects to it, tests start running. This URL is autogenerated and can differ every time tests are launched.

UPD: see the guide about the use of TestCafe in Docker: https://devexpress.github.io/testcafe/documentation/guides/advanced-guides/use-testcafe-docker-image.html

wentwrong
  • 711
  • 4
  • 7
Alexey Lindberg
  • 756
  • 3
  • 12
  • I tried using the plugin you mentioned but it's not working for me. I installed the plugin as mentioned in the link and then I ran my tests `testcafe browserless:chrome uitests/tests/logintest.js -e`. I get the error: `ERROR Was unable to open the browser "browserless:chrome" due to error. undefined` . I couldn't figure out what's the problem here, any idea how can I fix this? – Psdet Oct 28 '19 at 15:29
  • And for the remote connection, I have the URL but I need to use headless chrome as I'm running my tests on AWS. Any idea that this could work for headless? – Psdet Oct 28 '19 at 15:34
  • You can start Chrome browser in headless mode from the CLI by using the following command: `chrome --headless http://localhost:1337/browser/connect/6M9cgTu` Also, you might want to take a look at [this thread](https://stackoverflow.com/questions/9210765/any-way-to-start-google-chrome-in-headless-mode) with a similar question. – aleks-pro Oct 30 '19 at 13:48
  • @aleks-pro - that works but now I completely moved to docker. So, basically I have API, web, testcafe, chrome-headless everything in a docker container. I run `docker run --net=host -v `pwd`:/tests -e "NODE_PATH=/tests/node_modules" -it testcafe/testcafe --list-browsers` but I get output `firefox Chromium` but I was also expecting chrome which I have a docker container running. Is there a way I could get the access of `https://hub.docker.com/r/browserless/chrome` from TestCafe? – Psdet Oct 31 '19 at 19:35
  • As I understand, you want to run your tests in Google Chrome. The 'testcafe/testcafe' docker image is based on the Alpine Linux image. The Alpine Linux packages [registry](https://pkgs.alpinelinux.org/packages) doesn't contain the 'chrome' package. So, you can run your tests only in the Chromium browser. The Chrome and Chromium web browsers have the same script engine. So, if you want to guarantee that the tested web site works correctly, it's enough to run your tests with Chromium. – mlosev Nov 01 '19 at 09:46
  • @mlosev - Thanks. Will do it with Chromium. I probably own't do now after reading your above comment but just for my knowledge, is it theoretically possible to run a separate container of any headless browser (let's say chrome) and connect TestCafe when run on `testcafe/testcafe`image which I was originally trying to do? – Psdet Nov 01 '19 at 13:19
  • Speaking theoretically, you could use a remote connection for this, if you could open the URL provided by TestCafe in a headless browser in another container. I'm not very familiar with browserless, but as far as I understand, it does not provide such functionality. But there is a chance that some other docker image does. – Alexey Lindberg Nov 05 '19 at 15:13