I
recently started learning Selenium RC on my own. I read the materials
available on the Selenium RC website. This material assumes that you
are familiar with
Javaand JUnit concepts. Therefore, it is difficult to setup a working Selenium RC with Java for people having worked on
TestAutomation with limited knowledge of Java and JUnit.
Following are the 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. Create a new folder C:\selenium_tests (This would be the location where you will save the test classes).
7.
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;
8. Make sure that C:\jdk1.6\bin is included in your PATH environment variable.
9.
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.
10. Open a Command Prompt and go to the following location. C:\selenium-rc\selenium-server-1.0-beta-1
11. Type the following command to start the selenium RC
serverfor test execution.
>java -jar selenium-server.jar -interactive
12. Open another command prompt window and go the location where you saved GoogleTest.java file. i.e. C:\selenium_tests
13. Compile the java file with javac as
>javac GoogleTest.java
14. 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.