Tuesday 1 November 2011

Writing Selenium Tests in Eclipse


First we download Selenium IDE form http://seleniumhq.org/download/. It is a firefox plugin. Click on install
How to install Selenium IDE into your Browser.
Go to http://seleniumhq.org/docs/02_selenium_ide.html#installing-the-ide.
After Installation Selnium IDE will appear in Tools Menu

Click on Record Button on the Right Side corner OR Go to Action---> Click Record

Goto Url and Navigate some steps . After Navigation complete Stop Record.

Then we will get the script in Table format. If you want to source file click on source button. Default HTML code will appear.

If we want to write tests using java or csharp . Go to Options-->Format--->Select format --->Click OK.

If languages are not appear in the Format menu. Go to Options-->Options-->Select Enable Experimental Features. Now, we got the language options.

Copy the Entire code into your Class  Do the following changes in ur script.
1. Change Package name (i.e where our script appears.).  In the previouse example my script contains in com folde. So include this package like package com;
2. Change Untitled Class name to your Class name.
3. Click on Run. 

We will get the below after screenshot

If test passed Green Bar will appear otherwise Red Bar will appear. Don't forget to run selenium server before your test execution.

If you want ot run selenium tests using TestNG , instead of creating JUnit test case create TestNG Class.
Get the script by using TestNG (Remote Control) Format in Selenium IDE. Don't forget to add TestNG Jar file to your project.

No comments:

Post a Comment