Wednesday, October 5, 2011

Selenium RC

Overview of Selenium RC
While Selenium IDE may seem a productive and efficient tool for writing test-cases, it lacks many essential features of a testing tool:
Conditional statements
Loops
Logging
Exception handling
Reporting
Test fixtures and data-driven tests
Test dependencies
Taking screenshots
Selenium RC is the answer to a more powerful test-suite for your applications.
It follows a client/server model allowing client libraries to execute tests on a browser controlled by the server.



Selenium Server
• Selenium server is the program that drives the browser
• It embeds Selenium Core framework and injects it into the browser
• It communicates with the running test client and drives the browser
• Client tests sends commands that the server interpretes in order to drive the browser
• The server sends back results to the client
• Client and server communicates via HTTP GETs and POSTs so you can easily plug into
• Server is configurable at startup via command-line options. use java -jar selenium-server.jar -h to see the list of options
Client libraries
• Client libraries provides the API to program tests and execute them on the server
• Each implementation provides access to all Selenium commands
• Supported API implementation exists in:
- Java (also accessible via Groovy)
- Net
- PHP
- Python
- Perl
- Ruby


Installation of Selenium RC

Prerequisites
• A JVM installed on the system
• A Ruby distribution with the rspec and selenium-client gems installed if
• you’re working
• The Selenium RC archive


Running The RC Server
• Unzip the Selenium RC archive somewhere on your system
• Go into the selenium-rc, then the selenium-server folder
• Open a terminal in this folder and enter the command java -jar selenium-server.jar
• If there’s no error messages, your Selenium RC server should be running now.



Running A Test (Java)
• Create a new Java project in Eclipse or your Java IDE
• Add the selenium-java-client-driver.jar jar to the project’s classpath
• Add a new JUnit test-case to the project. When asked, select Junit 4
• You should now have an empty .java file
• Open the lab2 test-case on Selenium IDE
• On Selenium IDE, open the Options menu then Format… and click Java (Junit)
• Copy/paste the contents in the JUnit file on Eclipse
• Change the package name at your will
• You may have to fix the imports
o Click on the following icon and choose the most appropriate option to correct the file
o You may also press Ctrl + Shift + O to let Eclipse do it automatically
• At this point you shouldn’t have any more errors and you are ready to run the test
• Selenium RC will open a couple of Firefox windows and run the test


Junit
• Junit is the reference unit-testing framework for Java
• The framework allows you to test your applications using specific classes containing the logic performing actions on the tested classes and checking the results
• Eclipse provides support for Junit, so we’ll be using that
• JUnit 3 uses named methods to detect set-up and test methods

No comments:

Post a Comment