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 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
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:
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.
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
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 belowStarting 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.