Over a million developers have joined DZone.

Running Iridium Scripts in Firefox With Jenkins

DZone's Guide to

Running Iridium Scripts in Firefox With Jenkins

This article shows you how to configure Iridium, xvbf and Jenkins to run test scripts in Firefox in a headless environment.

· DevOps Zone ·
Free Resource

Open source vulnerabilities are on the rise. Read here how to tackle them effectively.

It is very common to run Iridium test scripts on a CI server like Jenkins or Bamboo as part of a web application build process. Typically these servers are headless, which is to say that the CI service is run from a terminal that has no graphical capabilities. This presents something of a challenge given that Iridium is running test scripts against graphical web apps.

A common solution is to use PhantomJS. This is a web browser that can be run in headless environments as it never actually displays anything on the screen. PhantomJS is a neat solution, but it does have some subtle issues that you will run into. One that I ran into was the fact that PhantomJS exposes touch events to the web applications it runs, which can in turn trick the apps into thinking they are running on a mobile device. The Ticket Monster JBoss demo application is one example of an application that will switch to mobile mode when run in PhantomJS.

Below is a screenshot of Ticket Monster when run in PhantomJS. Despite the large resolution, we’re still getting the mobile version.

Screen Shot 2016-08-09 at 4.19.10 PM.png

To test applications that don’t quite work as expected in PhantomJS, it is possible to run browsers like Firefox in a headless environment under Linux with xvfb. Xvfb provides a virtual screen that Firefox will render to, without needing a physical screen present to display the output.

Configuring xvfb and Jenkins on a Linux box is pretty easy. To start with, make sure you have xvfb and Firefox installed on your CI server. There are plenty of instructions on how to install these applications, and they will almost certainly be provided with your standard Linux package manager.

Next, install the Xvfb Jenkins plugin. We’ll use this plugin to manage xvfb as builds are started and stopped.

We’ll need to add some global environment variables in order for Firefox to work with xvfb. Click Manage Jenkins -> Configure System, and add a global environment variable called DISPLAY with the value :99. The number 99 is just something we make up, and we’ll use it again when configuring the Iridium Jenkins job.

Screen Shot 2016-08-09 at 4.30.05 PM.png

We then need to add an xvfb installation. Click Manage Jenkins -> Global Tool Configuration, and add an xvfb installation. On my server, the Install automatically option worked fine.

Screen Shot 2016-08-09 at 4.45.04 PM.png

Finally we need to configure the Iridium test build. In this example we’ll be executing the verification example that comes with Iridium by building Iridium from the source code in GitHub.

We give the project a name, and point it to the GitHub project URL.

Screen Shot 2016-08-09 at 4.34.08 PM.png

We define the location of the source code.

Screen Shot 2016-08-09 at 4.35.52 PM.png

We add a trigger to run the test whenever the Git repo is updated.

Screen Shot 2016-08-09 at 4.36.40 PM.png

Then we need to configure xvfb as part of the build. The important fields are Xvfb specific display name, which we set to 99 (just like the DISPLAY environment variable that we defined earlier), and Xvfb screen, which is set to 1920x1080x24 to reflect an averaged sized monitor. I also enable the Log Xvfb output option as it is useful for tracking down any errors that might occur.

Screen Shot 2016-08-09 at 4.37.28 PM.png

For the build section, we start by clearing out any old artifacts.

Screen Shot 2016-08-09 at 4.40.03 PM.png

Then we run Iridium via a Gradle build script. The Switches section contains the follow options:








The only thing that might stand out here is that I’ve set the Firefox location to /usr/bin/iceweasel, which is just a version of Firefox that is distributed with Debian (the OS that is hosting my Jenkins server).

Screen Shot 2016-08-09 at 4.40.57 PM.png

For the post build actions we save the Cucumber artifacts (log files, screenshots, reports), and parse the JUnit report file called MergedReport.xml.

Screen Shot 2016-08-09 at 4.43.25 PM.png

With this configuration in place, Iridium will run the test script in Firefox (or Iceweasel as the case may be with my Debian server), and the Ticket Monster application presents the full desktop experience.

Learn about the ins and outs of open source security and management.

server ,ci ,github ,url ,jenkins ,web ,iridium ,apps

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}