To perform UI testing your applications on DEV@cloud, you may need to have an X11 windowing server installed. You can of course also use the Sauce Labs Selenium testing feature of DEV@cloud, in which case, you don’t need to read further. The following is a guide for people running tests on DEV@cloud build servers.
There are several ways to acquire this X11 display
- the Xvnc plugin - https://wiki.jenkins-ci.org/display/JENKINS/Xvnc+Plugin
- use a virtual framebuffer - Xvfb
Install this plugin on your DEV@cloud account (JENKINS_URL/pluginManager/available) and restart Jenkins. A new option in job configuration let you enable Xvnc (virtual) graphical environment
export DISPLAY=:1 Xvfb :1 & ... gui code / tests ...
The main drawback for using Xvfb is that setting the graphical environment only applies to current shell script build step.
If you get an error similar to the following it means that you haven’t started Xvfb properly.
Caused by: java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it. at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159) at java.awt.Window.<init>(Window.java:432) at java.awt.Frame.<init>(Frame.java:403) at java.awt.Frame.<init>(Frame.java:368) at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1733) at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1810) at javax.swing.JDialog.<init>(JDialog.java:253) ... thousands more ...
export DISPLAY=:1 Xvfb :1 & node_version=v0.8.14 install_name=node-$node_version-linux-x64 node_home=$PWD/$install_name if [ ! -e $install_name.tar.gz ] then wget http://nodejs.org/dist/$node_version/$install_name.tar.gz tar xf $install_name.tar.gz $node_home/bin/npm install -g testacular fi export PATH=$PATH:$node_home/bin scripts/test.sh
Note that you also have to change the karma.conf.js file to have singleRun=true; so it stops when the tests have run.
You can of course run selenium-webdriver directly on the build servers if you wis. They will work nicely with the included browsers on the platform. This supports a variety of languages.
- Using Mocha and Chai with webdriver to make JS based testing easier - Also applicable to Sauce Labs!