Automated UI Testing With Jenkins and Selenium

One of the key tools we use to keep HiringThing (mostly) bug-free and working well is automated testing. Rails, our application framework, provides good tools for testing backend code, but we found a need to better test our user interface. The HiringThing UI involves many complex interactions between HTML , Javascript and server-side actions, and we needed integration testing that tests these components operating in concert.

To address this, we have series of tests that run through the application in a web browser, clicking and interacting with the app live. We use a combination of Capybara (automation), Selenium Web Driver (web browser interface) and Jenkins (continuous integration).

A challenge in this process was getting the web browser to run on a headless server. Our CI server with Jenkins lives in the Amazon Web Services cloud, and doesn’t have X-windows running on it. So, how do we get a web browser? Here is our solution.

Setting Up Headless Browser Automation

We started off by installing Xvfb , an X server that requires no display devices. Configuration consisted of little more than:

{% highlight bash %}
sudo apt-get install xvfb
{% endhighlight %}

The Jenkins build script looks like this:

With a little bit of Jenkins configuration, this process is fully automated. Now every time we check code into our master branch (on github), Jenkins runs all the tests, and drops me an IM message about 15 minutes later telling me whether they succeeded or not. Sweet!

blog comments powered by Disqus