Sunday, 11 July 2010

Selenium Grid Part 1 – Getting Started

I have been looking at Selenium Grid which is a tool that allows distributed multi platform and multi browser testing. I have found it is a bit like The Grinder and the How To guides seem to miss something, so I going to write about my initial set up and writing in hope it will help others get up and going with what looks like a really useful tool.

My initial setup will involve three Ubuntu VMs. One Ubuntu Server running the hub and two Ubuntu Desktops acting as the nodes. They were set up using the VMWare Player creation tool that does all the work for and installs VMWare Tools and hides most of the install prompts for to help speed the roll out. Then I changed the APT details to use my internal APT Mirror and updated, I also changed the time zone to be New Zealand and installed an SSH server. Everything else I have done the VMs will be list below as it will count as getting Selenium Grid up and running.

Install some things that are needed on all of the machines (sun-java6-jdk is the Canonical Partner repository):
  • sudo apt-get install unzip sun-java6-jdk ant ant-optional

I rebooted the systems after this so all the updates could apply and the PATHS all get updated.

On all of the machines download Selenium Grid ( and extract it

The ant sanity-check will check that everything is installed correctly

On the hub machine start the hub
  • ant launch-hub

Give it a little bit to start up and then go to the following URL and you can check that it is all up and running by looking at http://[hub ip]:4444/console

On each of the nodes run the following command to start the remote controls, you will have to do this from a terminal on the desktop, so it knows where the display is so can run your browser.
  • ant -Dport=5555 -Dhost=[node ip] -DhubURL=http://[hub ip]:4444/ launch-remote-control

Have a look at http://[hub ip]:4444/console and you should see your two nodes are connected.

On your desktop from the selenium-grid-1.0.8 directory run the following (you will need the JDK and Ant on this machine as well)

  • ant run-demo-in-parallel

On both of the desktops you will see Firefox open up a do stuff. It does fail as I believe Google has changed their site since the example tests were written. But you can see everything opening up and running the tests in parallel over the two desktops.

The Series:

Upcoming ideas for the series:
  • Putting the test suite in SVN and running from there



Unknown said...

Great job with the post, I am trying to setup the grid to run on multiple virtual machines which has different OS and browsers.

My machine A, i start the hub using: start java -jar C:\selenium-server\selenium-server-standalone-2.25.0.jar -role hub http://[ip]/grid/console -port 8000

My machine B, i start the node using:
java -jar selenium-server-standalone-2.25.0.jar -role node -hub http://localhost:8000/grid/console -port 5556

But on machine B I get message: 'couldn't register node: hub down or not responding.

I am not sure what I am doing wrong. Please provide your inputs.
I would really appreciate it.

Note: I am using Webdriver with Selenium.

Thanks a lot.