Setting up environment for Nightwatch.js and Chromedriver headless tests on Amazon EC2

I recently had to write some E2E functional tests for an application built on top of MEAN architecture. We had just shifted from Java + Selenium + JUnit combination to  Nightwatch.js + Chromedriver combo and it was working fine on development machines.

Chromedriver provides us with all that Selenium does and without adding Java dependency to the stack which is a big plus. On the downside, it is using relatively new W3C Webdriver API which does not have widespread community support like Selenium does. That aside, it effectively does what Selenium does and faster.

Let’s now get to the main point of this post. We use TeamCity + Amazon EC2 for deployment and we wanted to make the E2E tests part of our CI process. So, to make that happen we needed three things on our EC2 instance ready:

  • Google Chrome
  • Nightwatch.js
  • Xvfb

Google Chrome

To install Google Chrome run first we will have to cerate a Google Chrome repo like so:

Then, in that file add the following repo information

Note: An alternate i tried was to add gpg key using ‘rpm –import‘ format but that did not work as for some reason the Amazon variant of Fedora does not ship with —import flag.

After that you can get info about chrome using

And install it like so


You can install nightwatch from the npm repository

Display Server

That should have been enough, had it not been our requirement to run the tests in headless mode and we were running a desktop environment. But unfortunately, that was not so. Therefor, to install a display capabilities we had to install Xvfb.

On yum you first need to search for it

If yum has a repo for it then you will see in the resulting list. In any case, you can install the dependency using yum

Once both are installed, you can create a script having commands like below and run the tests in headless mode



Application developer, movie buff, occasional reader and a huge Manchester United fan.