Monday, May 24, 2010

Selenium RC Setup and Configuration

  1. Introduction
  2. Download and Configure Selenium RC JAVA, TestNG and Eclipse
  3. Test the Setup.
  4. Conclusion
Selenium RC Selenium-RC is the solution for tests that need more than simple browser actions and linear execution. Selenium-RC uses the full power of programming languages to create more complex tests like reading and writing files, querying a database, and emailing test results. You’ll want to use Selenium-RC whenever your test requires logic not supported by Selenium-IDE. What logic could this be? For example, Selenium-IDE does not directly support:
  • condition statements
  • iteration
  • logging and reporting of test results
  • error handling, particularly unexpected errors
  • database testing
  • test case grouping
  • re-execution of failed tests
  • test case dependency
  • screenshot capture of test failures
Although these tasks are not supported by Selenium directly, all of them can be achieved by using programming techniques with a language-specific Selenium-RC client library.  

Selenium RC Java client libraries Selenium RC Java 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.  

TestNG TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionality that make it more powerful and easier to use, such as:
  • JDK 5 Annotations (JDK 1.4 is also supported with JavaDoc annotations).
  • Flexible test configuration.
  • Support for data-driven testing (with @DataProvider).
  • Support for parameters.
  • Allows distribution of tests on slave machines.
  • Powerful execution model (no more TestSuite).
  • Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc...).
  • Embeds BeanShell for further flexibility.
  • Default JDK functions for runtime and logging (no dependencies).
  • Dependent methods for application server testing.
TestNG is designed to cover all categories of tests: unit, functional, end-to-end, integration, etc...  

Why use TestNG with Selenium RC ? Selenium IDE by itself is great for creating test cases and executing single tests. TestRunner is ok at running a test suite. But if you want full automation against different server and client platforms, you need a way to invoke the tests from a command line process, flexibility in how you create your test suites, and reports that tell you what happened. TestNG provides these features. You can use Selenium RC with other languages as well, but since Sakai is written in Java it makes sense to stick with the language most of us are familiar with already.  

Eclipse Eclipse is a multi-language software development environment comprising an integrated development environment (IDE) and an extensible plug-in system. It is written primarily in Java and can be used to develop applications in Java and, by means of the various plug-ins, in other languages as well, including C, C++, COBOL, Python, Perl, PHP, and others.  

ANT Ant is a Java library and command-line tool. Ant's mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications. Ant supplies a number of built-in tasks allowing to compile, assemble, test and run Java applications. Ant can also be used effectively to build non Java applications, for instance C or C++ applications. More generally, Ant can be used to pilot any type of process which can be described in terms of targets and tasks. 
2. Download Files (Always download Latest version)  

1. Selenium RC Package. • Download Selenium RC • Unzip the download file. • Copy “selenium-java-client-driver-1.0.1” and “selenium-server-1.0.3” to a location in your local system. Ex: C:\MyWorks\Live_Selenium_Files\selenium-java-client-driver-1.0.1 C:\MyWorks\Live_Selenium_Files\selenium-server-1.0.3  
2. Download TestNG • Download TestNG from • Unzip the download file. Ex: C:\MyWorks\Live_Selenium_Files\testng-5.11 
3. Download Eclipse (Eclipse IDE for Java Developers) • Download eclipse from • Unzip the package. Ex: C:\MyWorks\eclipse-ganymede 
4. Download ANT • Download ANT from • Unzip the ANT. Ex: C:\ant 
1. Make sure that you have Installed Java environment in your systems and classpath are configured respectively. 
2. Install TestNG plug-in for Eclipse 
• Open Eclipse. 
• Go to “Help>Software Updates…” and select “Available Software” tab. 
• Click on “Add site” and enter TestNG plugin download URL depending on your eclipse version. Ex: 
• Follow the instruction and complete the TestNG plugin installation. 
3. Make sure you have configured all the path (Classpath): Ex: 
• ANT_HOME C:\ant\;C:\ant\lib;C:\ant\bin;C:\ant\bin\ant.bat; 
• CLASSPATH %CLASSPATH%;C:\MyWorks\Live_Selenium_Files\junit-4.8.1.jar;C:\MyWorks\Live_Selenium_Files\selenium-java-client-driver-1.0.1\selenium-java-client-driver.jar;C:\MyWorks\Live_Selenium_Files\selenium-server-1.0.3\selenium-server.jar;C:\Program Files\Java\jdk1.6.0_10\bin;C:\Program Files\Java\jdk1.6.0_10\lib\tools.jar; 
• JAVA_HOME C:\Program Files\Java\jdk1.6.0_10\lib;C:\Program Files\Java\jdk1.6.0_10\bin;C:\Program Files\Java\jdk1.6.0_10;C:\Program Files\Java\jre6\bin;C:\Program Files\Java\jre6;C:\Program Files\Java\jdk1.6.0_10\bin\java.exe;C:\ant\;C:\ant\lib;C:\ant\bin;C:\ant\bin\ant.bat; 

3. Test the Setup 
1. Open command Prompt and Type “Java – version” Above screen shows the java is installed and Java classpath is set.  
2. Open command Prompt and Type “ant” Above screen shows the ANT is working fine.  
3. Open command Prompt • Navigate to selenium-server folder (Ex: C:\MyWorks\Live_Selenium_Files\selenium-server-1.0.3) • Type “java -jar selenium-server.jar” 4. Conculsion: By Using Eclispe IDE you can create Selenese script


  1. This comment has been removed by the author.

  2. Hi Friends,

    This blog is very useful for the beginners and also people who already started working on Selenium. I am expecting more updates in this blog on selenium versions as well as scripting tips and techniques.