Sunday, September 5, 2010

Configuring Selenium RC with TestNG using eclipse

Recently I was trying Selenium RC with TestNG using eclipse. I found it little tough without any proper step by step documentation. I took help of my collegues and completed. In fact I am not using this tool in my project but I always try to find time to work with selenium. After all you can not stop your learning :)
This tool is pretty good and rapidly taking place in market.

Any way I had successfully ran a sample test case using TestNG in eclipse with selenium RC. While it was starting but decided to post one article on “Configuring Selenium RC with TestNg using eclipse” to help testers those who want to start with same. I also maintain my blog as a database for self reference. So if you find it beneficial for you, you can write few words and if not then you can ignore :(



Finally here, step by step process to configure and run your first java test using TestNG and selenium RC in eclipse

1- Install JRE http://www.java.com/en/download/
2- Download eclipse http://www.eclipse.org/downloads/
3- Download TestNG http://testng.org/testng-5.14.zip
4- Download selenium RC http://seleniumhq.org/download/
5- Launch you eclipse

The workspace, you can select any working directory. In my case it’s “Selenium_Project”


Now clicking on Ok button, it will launch eclipse.




6- Install TestNG plugin

Go to help->install new software






Click on add. This will open a small window where you need to put location “http://beust.com/eclipse”.

Click on OK. You will see that an entry is added there. Now tick that box and click on next.



7- Add project

Click File->new->Java project

Give project name and finish


 

 
This will create project “MyProject”




8- Add TestNG jar to library

Select MyProject and then Go to (menu bar) project->properties->Java build path->Libraries



Click on add external JARs and add TestNG jar file (testng-5.14.jar) from folder which you get after downloading TestNG in step#3.



9- Add Selenium RC jar to library

Add selenium Jar file same way we have added testNG jar. Selenium jar file can be found in the “selenium-java-client-driver-1.0.1” folder which you get after downloading it in step#4.





10- Add Class file

In MyProjectt right click on scr folder then new->class


Name the class (e.g Login) and finish.


Now add your test code here under this class. As in my previous article I had mentioned that you can simply record your test using IDE and pick java code and use here. For more detail refer : http://vishalsachan.blogspot.com/2010/06/hi-folks-sorry-for-bieng-inactive-from.html



11- Run test

Run your clas file as TestNG





Ohh i forget one step here. before executing test/running class file you need to start selenium server. thia is similar to every time so i am just copying it from my previous article.



To start the selenium test server, first go to the location where your JRE is placed. For example
C:\Program Files\Java\jre6\bin\
and then Run the command java -jar selenium-server.jar
here it is supposed that you have placed your selenium -server.jar file in same location. In case if you have placed it in other location you can run it in following way:

C:\Program Files\Java\jre6\bin\java -jar jar “E:\SELENIUM\selenium-remote-control-1.0-beta-1\selenium-server-1.0-beta-1\selenium-server.jar”

This will start you selenium server.


Thanks.