Selenium RC tutorial

Hi…. This Blog would be a tutorial about Selenium RC, since there is no good tutorial about selenium RC i tought of starting my own blog. I’m a learner hence i would be updating in regular intervals. selenium rc tutorial


In This blog i would try to cover the following topics:

1> Introduction to Selenium-IDE
2> Installation of Selenium RC
3> Automated Testing


1>Introduction to
selenium-IDE

selenium rc tutorial – Selenium IDE is a Firefox add-on, which can be easily downloaded through Firebox add-ons option in tools. It helps to record, edit and debug our tests. Wat do we mean by tests here, it might be a list of actions over any website or your homepage. By running such actions(tests), recording it and running the tests, it helps us realise the backdrops and hence rectify the defects of our webpage for a better performance.

Selenium IDE is not only recording tool: it is a complete IDE. You can choose to use its recording capability, or you may edit your scripts by hand. With autocomplete support and the ability to move commands around quickly, Selenium IDE is the ideal environment for creating Selenium tests no matter what style of tests you prefer.

Features:

  • Easy record and playback
  • Intelligent field selection will use IDs, names, or XPath as needed
  • Autocomplete for all common Selenium commands
  • Walk through tests
  • Debug and set breakpoints
  • Save tests as HTML, Ruby scripts, or any other format
  • Support for Selenium user-extensions.js file
  • Option to automatically assert the title of every page

Recording a test using Selenium IDE:

Install the selenium IDE add-on, After Firefox reboots you will find the Selenium-IDE listed under the Firefox Tools menu.



Selenium IDE opens as follows with an empty script-editing window and a menu for loading, or creating new test cases.


Now to record a new test, just click the record symbol at the top right corner of the selenium IDE window, and perform all the actions on a blank page for example,

  • open www.mail.yahoo.com
  • type your username and password
  • and signout
these actions will be recorded in Selenium IDE as follows:


As you can see from above signing in and signing out in yahoomail has been recorded. To run the recorded tests, the play button can be clicked which runs every single step automatically and shows the commands in highlighted green if the tests results are correct and shows in red if there was an error. When i say it runs the tests automatically i really mean it, it opens a new firefox page opens yahoomail, and signs out automatically.

Need of Selenium RC:

I hope you might have got a gist of what selenium IDE is and its basic functionality.
Ok so y do we need selenium RC when all the tests can be recorded and run in selenium IDE itself?????

  • to run several similar test cases at a stretch,
  • to run the test cases in different browsers,
  • to run the test cases in different os,
  • to run the test cases from an external server

The above procedure holds good for a single test now when we need to create a series of similar test cases or edit the prevailing test and make it run automatically from an external server we go in for Selenium RC. Selenium IDE allows us to export the recorded results as Perl,ruby,java etc scripts. The main advantage of selenium testing is it runs our selenese commands from your test program on any no of browsers and OS at the same time.

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 browser’s 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.

2>Installation of Selenium-RC

Selenium RC is a test tool that allows writing tests in any programming language. This tool is useful in test cases that need logic not supported by Selenium IDE. For example you might need to capture screenshots depending on the results of a certain action; in this case you can export your test case to your preferred language and modify the code to implement the desired behavior.

RC Components

Selenium RC works with these 2 components: Remote Control Server and Client Libraries.

Remote Control Server receives the Selenium commands from the test program using HTTP GET/POST requests. Each command is passed to the browser using Selenium-Core JavaScript commands. “Selenium-Core is a JavaScript program, actually a set of JavaScript functions which interprets and executes Selenese commands using the browser’s built-in JavaScript interpreter.” (Selenium RC)
Client Libraries are the Interface between each programming language and Selenium-RC server; they provide a programming function for each Selenese command. Client libraries pass the Selenese commands to the Selenium Server, then receive the result of the command and pass it to the test program. You can store the result of the command as a variable and do a specific action in your program, for example take a screenshot if the result is interpreted as “failed”.

Selenium-RC Installation

I am assuming Java is installed and PATH environmental variable is configured.
Step 1: Download Selenium RC Zip file from: http://seleniumhq.org/download/
Unzip the file to a folder named selenium-rc in c drive. (There will be a folder per supported language and selenium-server folder which contains the selenium-server.jar which is the Selenium-RC server)

Step 2: As we are going to use a Java file (to run the server), we have to install JUnit to be used as our test engine. To install JUnit, simply:

  • Download latest version of JUnit from: http://sourceforge.net/projects/junit/files/
  • Unzip Junit.zip file
java org.junit.runner.JUnitCore org.junit.tests.AllTests
All tests should pass with OK message.(JUnit)

Starting Selenium Sever

1. Go to the command-line console
2. Run the command [in selenium server path ]:
java -jar selenium-server.jar
Selenium-server will start running as shown below

Starting Selenium Sever in linux:

To start the Selenium-server on a linux machine, java.jdk and java.jre need to be installed first.

sudo apt-get install sun-java6-jdk

sudo apt-get install sun-java6-jre

To run the server(shud run in a seperate console) : java -jar selenium-server

To run the test case(shud run in a seperate console) : go to selenium-perlclientdriverf

perl filename.pl


3>Automated testing

After understanding how to use Selenium IDE and after installing Selenium RC, the test can be run through selenium RC server.
Run the selenium server as shown above, open a new command prompt and go to the directory on which language you are working upon, as shown below

here the test case can be called as,

C:\selenium-rc\selenium-perl-client-driver-1.0.1>perl testcase.pl

note: these actions should be done in a seperate command prompt leaving the command prompt dat runs the server.
selenium rc tutorial, selenium rc tutorial, selenium rc tutorial, selenium rc tutorial.

2 Responses to “Selenium RC tutorial”

  1. Hammer says:

    Hi,Nice to see your work. All the best.I had a query. I have very rich programming and dpevloeement experience and have been working with some game engines. But iam very new to online games technology.I wish to develop a multiplayer car racing online game. Can you please tell me which would be the best technologies to use?I heard it can be done with flex as well as java. But i heard that with flex, your games are not full screen. I want to make full screen games. Also if possible i want to add 3D graphics.Please drop in your suggestions.Thanks and Regards

  2. Lisa says:

    I haven’t gotten Selenium intgerated yet in my build process. Mike (Henke) has some great examples on my wiki. I’m going to need to crack down and do it for my current project and when I do I’ll blog about it!At some point I’d like to do another preso for TACFUG on more advanced ANT stuff external properties, compressing your JS/CSS files, and Selenium.Too much to do and not enough time in the day!!

Top
Follow

Get every new post delivered to your Inbox

Join other followers