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.
- 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:
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 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 works with these 2 components: Remote Control Server and Client Libraries.
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
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
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,
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.