Friday, January 7, 2011

PRACTICUM: Selenium 1.0 Testing Tools: Chapter 6: First Steps with Selenium RC

This is the sixth entry for the TESTHEAD PRACTICUM review of PACKT Publishing's book Selenium 1.0 Testing Tools Beginners Guide by David Burns. The emphasis on this type of review is the actual exercises and the practical applications of what we learn. Rather than reprint out the full listing of the exercises in the book (and there are a bunch of them, as that is the format of this particular title), much of these chapters are going to be a summary of the content, some walk-through of application, and my take on what I see and do.

Selenium 1.0 Testing Tools is full of examples, "try it yourself" instructions and explanations of what happened. The book’s cover states “Learn by doing: less theory, more results”. The focus will be less on the concepts and more on the actual implementation and methods suggested.

Chapter 6: First Steps with Selenium RC

The Selenium IDE is a nice little tool to work with and help put together tests, run them and review the results. It does have a couple of disadvantages though. First, the IDE is an Add-In to Firefox, and as such, native tests are only going to run on Firefox. That leaves all other browsers out of the mix.

The second is that tests using the IDE are limited to Selenese and its HTML table method of constructing tests. While there is extensibility to the IDE, it may be desirable to implement tests in a preferred language.

Both of these challenges are covered by using Selenium RC (Remote Control).

In this chapter we shall cover topics such as:

  • What is Selenium Remote Control
  • Setting up Selenium Remote Control
  • Running Selenium IDE tests with Selenium RC
  • Selenium RC arguments


The Java Runtime Engine (JRE) is required to make use of Selenium RC. JRE allows Java code to run on multiple machines (Mac, Linux and Windows). For this purpose, Selenium RC has been written in Java. You can download the JRE from Install it in a convenient directory and then add the executable path to the PATH values for your system.

What is Selenium Remote Control

Patrick Lightbody originally developed Selenium RC to test many different web web browsers without having to install Selenium Core (another Selenium app we will talk about later) on the web server. Originally developed to act as a proxy between the application and test scripts running against Selenium Core on web servers, Selenium Core is now bundled along with Selenium Remote Control.

What this change allowed was the ability to have developers directly interact with the proxy, plus allowing developers and testers the opportunity to use one of their preferred programming languages to send commands to the browser.

Java and C# have been, to date, the main languages used by developers to create Selenium Tests. Mainly because those are the languages most oft used to create web pages and web elements. More recently, testers and developers have added Ruby and Python to the list of often used languages for selenium RC tests. Whichever language used, the ability to use a programming or scripting language opens up many possibilities for flow control, reporting, string manipulation, etc., and can be used to help build a robust and flexible harness for testing.

Setting Up Selenium Remote Control

Selenium RC will need to be installed on any machines that will be driving your tests. David recommends limiting the number of instances of Selenium RC to one per CPU core to allow for the best throughput and performance.

1. Download Selenium Remote Control from  
2. Extract the ZIP file.
3. Start a Command Prompt or a console window and navigate to where the ZIP file was extracted.
4. Run the command java –jar selenium-server.jar (the book says to run selenium-server-standalone.jar, but my download didn't have that file name) and the output should appear similar to the following:

C:\selenium-remote-control-1.0.3\selenium-server-1.0.3>java -jar selenium-server.jar

21:45:52.992 INFO - Java: Sun Microsystems Inc. 19.0-b09
21:45:53.065 INFO - OS: Windows 7 6.1 x86
21:45:53.266 INFO - v2.0 [a2], with Core v2.0 [a2]
21:45:54.180 INFO - RemoteWebDriver instances should connect to:
21:45:54.184 INFO - Version Jetty/5.1.x
21:45:54.206 INFO - Started HttpContext[/selenium-server/driver,/selenium-server
21:45:54.222 INFO - Started HttpContext[/selenium-server,/selenium-server]
21:45:54.223 INFO - Started HttpContext[/,/]
21:45:54.589 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@17943a
21:45:54.590 INFO - Started HttpContext[/wd,/wd]
21:45:54.619 INFO - Started SocketListener on
21:45:54.620 INFO - Started org.openqa.jetty.jetty.Server@c40c80

We have now set up Selenium Remote Control  successfully . Our tests will communicate with the web browser via this control.

Running Selenium IDE tests with Selenium Remote Control

Using Selenium IDE to create all of our tests has a major drawback. We have only been testing our applications with Firefox! There are lots of different browser and O.S. combinations, and to cover them all would be daunting (and impossible with just the Selenium IDE).

To run Selenium tests on an Internet Explorer Browser (or any browser other than Firefox w/ the IDE installed), Selenium Remote Control will need to be installed. In addition, a location to find the test suite file will need to be supplied (using the -htmlsuite argument) and a location to store the results.

Selenium RC is run from the command prompt or console window, and will look like the following (adjust path names for your own system, the forward slashes are just used  to make the command more readable and understand the pieces required; to run the command, it would need to all be on one line):

java –jar selenium-server.jar \
–htmlsuite \
*[browserType] \
http://[fullUrlPath] \
c:\path\to\testsuite.html \

When the test starts running it will launch two browser windows. The first window will hold the Selenium Core Framework (Test Suite on the left, the test steps in the middle, the results on the right).

By using the –htmlsuite argument, Selenium IDE tests can be run through Selenium Remote Control.

Running your Selenium IDE tests in Internet Explorer

Internet Explorer, by way of market share and number of users, is still in the #1 spot. Internet Explorer comes
bundled with Microsoft operating systems, Therefore, we need to make sure that our code works on at least the latest version of IE (but don't be surprised if there are still those who use IE6). So how do we do that?

Now that we are aware that we need to make sure that our web applications work in Google
Chrome (really, I thought we were talking about Internet Explorer ;) ), let us have a look at how we can make our Selenium IDE tests work on the IE Explorer as well:

1. Open up a Command Prompt or console window.

2. Use the command:

 java –jar selenium-server.jar \
–htmlsuite \
*iexplore \ \
c:\path\to\testsuite.html \

and press Return.

Running your Selenium IDE tests in Google Chrome

Google Chrome is a WebKit-based browser. The most popular browser of this type is Google Chrome. In
this section we will have a look at running our Selenium IDE tests within Google Chrome.
This will help us make sure that we have sufficient coverage of our application.

1. Open up a Command Prompt or console window.
2. Use the command:

java –jar selenium-server.jar \
–htmlsuite \
*googlechrome \
c:\path\to\testsuite.html \

and press Return.

Below is the list of browsers, as of this writing, that are supported by Selenium Remote Control:

  • firefox
  • mock
  • firefoxproxy
  • pifirefox
  • chrome
  • iexploreproxy
  • iexplore
  • firefox3
  • safariproxy
  • googlechrome
  • konqueror
  • firefox2
  • safari
  • piiexplore
  • firefoxchrome
  • opera
  • iehta
  • custom

Running your Selenium IDE tests with the User Extensions

If you have created user extensions, you can also create suites where the tests and extension can be called up and included with the defined tests. There's an additional option and call added to the command to do this.

1. Open a Command Prompt or console window.

2. Use the command:

java –jar selenium-server-standalone.jar \
–userExtensions \\path\to\extensions.js \
-htmlsuite *firefox \ \
c:\path\to\testsuite.html \

(Note: interesting that the various commands interchange between selenium-server-standalone.jar and selenium-server.jar. This may have been an editing oversight).

Selenium Remote Control arguments

The following is a list of the most common Selenium Remote Control arguments and how we can use them:


Since Selenium Remote Control acts as a proxy between your tests and the application being
tested, it has to use a port to listen for commands. There will be instances where you will not
be able to use the standard 4444 port. When this happens, adding –port
allows you to use a different port number without conflicts.



We have already seen this in action. If you have created a user extension command in
Selenium IDE, it can be used with Selenium Remote Control. By using –userExtensions
c:\path\to\file.js we can access all the extra commands in our tests.


If you require a special profile, or if you need to make sure that a specific Firefox Add-on
is installed, use –firefoxProfileTemplate /path/to/firefox/profile. This
command will take the profile that you want and then clone it to be used in your test.

Update: While the above are the commands and the structure, this does not look to be working correctly with Selenium Remote Control 1.0.3 on Windows or any of the versions of Remote Control that I have tried. Since this is meant to be a Practicum, and since the book recommends using Ubuntu Linux, this may well be one of the points where this is working on one environment and not another, but as of this writing, I need to be clear that the steps above do not work on Windows XP or Windows 7.
Post a Comment