Ubuntu Server 10.10/11.04 – Selenium Server (headless) & PHPUnit

This tutorial explains how to run Selenium test cases with Selenium Server and PHPUnit on a Linux server that has no GUI (headless).

Make sure you have pear installed. Then upgrade to at least version 1.9.2

pear upgrade pear

Install firefox

apt-get install firefox

In order to run firefox on a headless server (means without a GUI), Xvfb (X virtual frame buffer) must be used. To install it:

apt-get install xvfb

Install Java:

apt-get install openjdk-6-jre-headless

Download Selenium Server and put it on your server, for example: /opt/selenium-server.jar. http://seleniumhq.org/download/ or direct link http://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.0rc2.jar&can=2&q=

Install PHPUnit – http://www.phpunit.de/manual/3.5/en/installation.html

pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover
pear.symfony-project.com
pear install phpunit/PHPUnit

Now everything is installed successfully.

Let’s start things up

Xvfb :99 -ac -screen 0 1024x768x8 > /tmp/xvfb.log 2>&1 &
export DISPLAY=localhost:99.0 && java -jar /opt/selenium-server-standalone-2.0rc2.jar > /tmp/selenium_server.log 2>&1 &

Now you can execute your Selenium PHPUnit testcase.

phpunit selenium_phpunit_testcase.php
Tags: ,,,