99

Setup headless selenium server

We wanted to automate our selenium tests so that we could run them through our continuous integration server (hudson). The problem was that the linux box that run hudson did not have a display. Initially I did not think much of that but soon realized that although the selenium server was running on port 4444, all of my tests were failing. This was down to the fact that selenium could not start Firefox successfully.

Although I am no expert on the matter, it appears that to run Firefox you need a way to display stuff (which kind of makes sense!). Since I had no display available I had to find an alternative. The solution is Xvfb.

So, first install Xvfb:

sudo apt-get install xvfb

Then start xvfb:

Xvfb :99 -ac

If all goes well then display 99 is used by xvfb. You can now run the selenium server (but you have got to let it know about the display).

DISPLAY=:99 java -jar selenium-server-standalone-2.4.0.jar

From then on you are good to go. Happy testing!



comments powered by Disqus