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
To install Google Chrome run first we will have to cerate a Google Chrome repo like so:
sudo nano /etc/yum.repos.d/google-chrome.repo
Then, in that file add the following repo information
Note: An alternate i tried was to add gpg key using ‘rpm –import key_url.pub‘ 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
yum info google-chrome-stable
And install it like so
yum install google-chrome-stable
You can install nightwatch from the npm repository
npm install nightwatch -g
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
yum search xorg-x11-server-Xvfb
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
sudo yum install xorg-x11-server-Xvfb
Once both are installed, you can create a script having commands like below and run the tests in headless mode
sudo nohup Xvfb :40 -ac -screen 0 1600x900x24 &
Latest posts by alexey (see all)
- Zend Soap NULL Reponse - August 29, 2018
- Quick Facts About WooCommerce - April 25, 2018
- WordPress stuck on a “Too many redirects” error loop when using SSL - January 17, 2018