0% found this document useful (0 votes)
110 views6 pages

Introduction To Selenium RC: Brief History of The Selenium Project

Selenium RC was previously the main Selenium project, but has been superseded by Selenium 2 and WebDriver. Selenium RC still supports several languages and browsers. It works by having a Selenium Server launch and control browsers, interpret Selenium commands from test scripts, and act as an HTTP proxy between the browser and web application being tested. The client libraries allow programming languages to communicate with the Selenium Server to run tests. To use Selenium RC, one installs the Selenium Server, sets up a test project using a client library for their chosen language, writes test code that executes Selenium commands, and runs the tests via the Selenium Server.

Uploaded by

Shwetha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views6 pages

Introduction To Selenium RC: Brief History of The Selenium Project

Selenium RC was previously the main Selenium project, but has been superseded by Selenium 2 and WebDriver. Selenium RC still supports several languages and browsers. It works by having a Selenium Server launch and control browsers, interpret Selenium commands from test scripts, and act as an HTTP proxy between the browser and web application being tested. The client libraries allow programming languages to communicate with the Selenium Server to run tests. To use Selenium RC, one installs the Selenium Server, sets up a test project using a client library for their chosen language, writes test code that executes Selenium commands, and runs the tests via the Selenium Server.

Uploaded by

Shwetha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Introduction to Selenium RC

As you can read in Brief History of The Selenium Project, Selenium RC was
the main Selenium project for a long time, before the WebDriver/Selenium merge
brought up Selenium 2, the newest and more powerful tool.
Selenium 1 is still actively supported (mostly in maintenance mode) and
provides some features that may not be available in Selenium 2 for a while,
including support for several languages (Java, Javascript, Ruby, PHP, Python, Perl
and C#) and support for almost every browser out there.

How Selenium RC Works


First, we will describe how the components of Selenium RC operate and
the role each plays in running your test scripts.
Selenium RC components are:
The Selenium Server which launches and kills browsers, interprets and
runs the Selenese commands passed from the test program, and acts as
an HTTP proxy, intercepting and verifying HTTP messages passed between
the browser and the AUT.
Client libraries which provide the interface between each programming
language and the Selenium RC Server.
Here is a simplified architecture diagram....

The diagram shows the client libraries communicate with the Server
passing each Selenium command for execution. Then the server passes the
Selenium command to the browser using Selenium-Core JavaScript commands.
The browser, using its JavaScript interpreter, executes the Selenium command.
This runs the Selenese action or verification you specified in your test script.

Selenium Server
Selenium Server receives Selenium commands from your test program,
interprets them, and reports back to your program the results of running those
tests.
The RC server bundles Selenium Core and automatically injects it into the
browser. This occurs when your test program opens the browser (using a client
library API function). Selenium-Core is a JavaScript program, actually a set of
JavaScript functions which interprets and executes Selenese commands using
the browsers built-in JavaScript interpreter.
The Server receives the Selenese commands from your test program using
simple HTTP GET/POST requests. This means you can use any programming
language that can send HTTP requests to automate Selenium tests on the
browser.

Client Libraries
The client libraries provide the programming support that allows you to
run Selenium commands from a program of your own design. There is a different
client library for each supported language. A Selenium client library provides a
programming interface (API), i.e., a set of functions, which run Selenium
commands from your own program. Within each interface, there is a
programming function that supports each Selenese command.
The client library takes a Selenese command and passes it to the Selenium
Server for processing a specific action or test against the application under test
(AUT). The client library also receives the result of that command and passes it
back to your program. Your program can receive the result and store it into a
program variable and report it as a success or failure, or possibly take corrective
action if it was an unexpected error.
So to create a test program, you simply write a program that runs a set of
Selenium commands using a client library API. And, optionally, if you already
have a Selenese test script created in the Selenium- IDE, you can generate the
Selenium RC code. The Selenium-IDE can translate (using its Export menu item)
its Selenium commands into a client-drivers API function calls. See the
Selenium-IDE chapter for specifics on exporting RC code from Selenium-IDE.

Installation
Installation is rather a misnomer for Selenium. Selenium has set of libraries
available in the programming language of your choice. You could download them
from downloads page.
Once youve chosen a language to work with, you simply need to:
o
o

Install the Selenium RC Server.


Set up a programming project using a language specific client
driver.

Installing Selenium Server


The Selenium RC server is simply a Java jar file (selenium-serverstandalone-<version-number>.jar), which doesnt require any special
installation. Just downloading the zip file and extracting the server in the desired
directory is sufficient.

Running Selenium Server


Before starting any tests you must start the server. Go to the directory
where Selenium RCs server is located and run the following from a commandline console.
java -jar selenium-server-standalone-<version-number>.jar
This can be simplified by creating a batch or shell executable file (.bat on
Windows and .sh on Linux) containing the command above. Then make a
shortcut to that executable on your desktop and simply double-click the icon to
start the server.
For the server to run youll need Java installed and the PATH environment
variable correctly configured to run it from the console. You can check that you
have Java correctly installed by running the following on a console.
Java version
If you get a version number (which needs to be 1.5 or later), youre ready
to start using Selenium.

Using the Java Client Driver

Download Selenium java client driver zip from the SeleniumHQ


Extract selenium-java-<version-number>.jar file
Open your desired Java IDE (Eclipse, NetBeans, IntelliJ, Netweaver, etc.)
Create a java project.
Add the selenium-java-<version-number>.jar files to your project as
references.
Add to your project classpath the file selenium-java-<version-number>.jar.
From Selenium-IDE, export a script to a Java file and include it in your Java
project or write
your Selenium test in Java using the selenium-java-client API. The API is
presented later in this chapter. You can either use JUnit, or TestNg to run
your test, or you can write your own simple main() program. These
concepts are explained later in this section.
Run Selenium server from the console.
Execute your test from the Java IDE or from the command-line.

From Selenese to a Program

The primary task for using Selenium RC is to convert your Selenese into a
programming language. In this section, we provide several different languagespecific examples.

Sample Test Script


Lets start with an example Selenese test script. Imagine recording the following
test with Selenium- IDE.

Selenese as Programming Code


Here is the test script exported (via Selenium-IDE) to each of the supported
programming languages. If you have at least basic knowledge of an objectoriented programming language, you will understand how Selenium runs
Selenese commands by reading one of the example below.
package com.example.tests;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
public class NewTest extends SeleneseTestCase
{
public void setUp() throws Exception
{
setUp( "http://www.google.com/" , "*firefox" );
}
public void testNew() throws Exception
{
selenium.open( "/" );
selenium.type( "q" , "selenium rc" );
selenium.click( "btnG" );
selenium.waitForPageToLoad( "30000" );
assertTrue(selenium.isTextPresent( "Results * for selenium rc" ))
}
}

Programming The Test


Now well illustrate how to program your own tests using examples in each
of the supported programming languages. There are essentially two tasks:
Generate your script into a programming language from SeleniumIDE, optionally modifying the result.
Write a very simple main program that executes the generated
code.
Optionally, you can adopt a test engine platform like JUnit or TestNG for Java, or
NUnit for .NET if you are using one of those languages.
Here, we show language-specific examples. The language-specific APIs tend to
differ from one to another, so youll find a separate explanation for each.
JAVA

C#
PHP
Pytho
n
Perl
Ruby

Java
For Java, people use either JUnit or TestNG as the test engine. Some
development environments like Eclipse have direct support for these via plug-ins.
This makes it even easier. Teaching JUnit or TestNG is beyond the scope of this
document however materials may be found online and there are publications
available. If you are already a java-shop chances are your developers will
already have some experience with one of these test frameworks.
You will probably want to rename the test class from NewTest to
something of your own choosing. Also, you will need to change the browseropen parameters in the statement:

You might also like