Explaining how the real world works!     RSS Feed The Automated Tester on Twitter The Automated Tester on LinkedIn The AutomatedTester on github

Selenium Tutorial to set up a Selenium Grid

Sun 27 Apr 2008

This tutorial walks you through the process of setting up Selenium Grid. I am going to first discuss the idea of Selenium Grid.

Selenium Grid is a Selenium derivative that allows the developer/tester to access Selenium Remote Controls without worrying about where the Selenium Remote Controls are. You as a developer/test create your script as you would for Selenium Remote Control and run it as normal. This is good if you want to test a bug with a specific browser but can't have it installed locally like multiple versions of Internet Explorer.

NOTE: Selenium Grid can only be controlled by Selenium Tests in a programming language. You will NOT be able to run Selenium HTML Test suites against it.

  1. You will need to download and install the latest Java JRE on your system. You can find this at http://java.sun.com .
  2. Once you have installed it, open up a command prompt and run java -version. It should look something like the image below.
    Java Version
  3. You need to check that you have Apache Ant. If you open up a terminal/command prompt and type ant -version. If it doesnt return an error then you should be fine. If it returns an error you will need to download Apache Ant and expand the archive to a folder on harddrive.
  4. You will need to now download Selenium Grid and put that in a folder that is easy to access. Now that we have all the relevant parts installed lets start the grid up.
  5. We are going to start up the Selenium Grid Hub first. Open up a command prompt or terminal and navigate to the folder where the Selenium Grid files are stored.
  6. From the command prompt run ant launch-hub. This will get the hub running. To see it running put http://localhost:4444/console into a browser and you will be shown a webpage with 3 columns. The first column shows what Environments it can handle, the second column shows what remote controls are available and the third column shows what remote controls are currently running tests. Like the following screenshot
  7. Now that we have our hub running, lets start up a remote control. Open up another command prompt or terminal and navigate to the Selenium Grid folder. Run ant launch-remote-control. This will launch a Selenium Remote Control for handling Firefox on your OS on port 5555
  8. We now have a Selenium Grid up and running! Lets run some tests against it. Run through the C# and Selenium Tutorial. You won't have to change a thing to get the tutorial to do what you want.
  9. To setup an node for Internet Explorer you need to run it as ant -Dport=5556 -Denvironment=*iexplore launch-remote-control. If you Selenium Grid node is not on the same machine as the hub just add -DhubURL=<Address of Hub> -Dhost=<Name of Node>
  10. I hope that you find this really useful. I will publish a tutorial on running tests concurrently.

One last thing, if you are running your tests on your Grid and the machine dies and you want to remove it from your grid just run http://<hub machine>:4444/registration-manager/unregister?host=<node machine>&port=<Port the Grid node is listening on>&environment=<environment it was setup for> in a browser and it will unregister it from the hub. This last bit of information will make life a lot easier for you.  e.g http://localhost:4444/registration-manager/unregister?host=locahost&port=5556&environment=*iexplore

    Area: tutorials

blog comments powered by Disqus