Wednesday, April 1, 2009

Few simple steps to set up Junit & Eclipse & Selenium

Hello everyone - I recently started learning Selenium IDE & Selenium RC & JUNIT. I read the materials available on the Selenium RC website.(www.openqa.org)

This material assumes that you are familiar with Java and JUnit concepts. Therefore, it is difficult to setup a working Selenium RC with Java for people having worked on Test Automation with limited knowledge of Java and JUnit.

Following are the 15 easy step by step instructions to setup Selenium RC with JUnit for test execution.

1. Download Selenium RC from www.openqa.org

2. Extract the files to the following location C:\selenium-rc

3. Download JUnit 4.4 from www.junit.org.

4. Extract the files to the following location C:\junit4.4

5. Download and Install JDK 1.6 or above to the following location C:\jdk1.6

6.One thing to note if you are using eclipse to run the JUNIT make sure you have it installed to your root directory. ( Please check my othe archive where I explain how to work on ecplise)

7. Create a new folder C:\selenium_tests (This would be the location where you will save the test classes).

8. Set an environment variable CLASSPATH as C:\selenium-rc\selenium-java-client-driver-1.0-beta-1\selenium-java-client-driver.jar;C:\selenium_tests\;C:\junit4.4\junit-4.4.jar;

9. Make sure that C:\jdk1.6\bin is included in your PATH environment variable.

10. Download the GoogleTest.java from the Java Tutorials available for Selenium RC at www.openqa.org. Save this file under selenium_tests directory you made eariler.

11. Open a Command Prompt and go to the following location. C:\selenium-rc\selenium-server-1.0-beta-1

12. Type the following command to start the selenium RC server for test execution.
>java -jar selenium-server.jar -interactive

13. Open another command prompt window and go the location where you saved GoogleTest.java file. i.e. C:\selenium_tests

14. Compile the java file with javac as
>javac GoogleTest.java


15. This would create a class file that you can run with JUnit for testing purposes as
>java junit.textui.TestRunner GoogleTest

You will notice that it would open a firefox session with Selenium Test Runner and execute the tests. In the end you will get the status of the test result on the command prompt as
C:\Selenium>java junit.textui.TestRunner GoogleTest.Time: 5.769
OK (1 test)

This shows that you have successfully run GoogleTest.java as a Selenium RC test using JUnit.
You can experiment editing GoogleTest.java and see the changes in the output.
I would also recommend using Selenium IDE for recording a new test, saving it as Selenium RC Java test and then executing it using Selenium RC and JUnit.

I hope this helps news users like me to better setup and understand Selenium RC.
I am also working on defining a Test Automation Framework that involves Selenium RC, Selenium IDE, Firebug, XML and TestNG.
I would keep posting my findings and step by step instructions on this blog. Keep Reading!!!

No comments:

Post a Comment