Site Loader
Auckland, New Zealand
The latest version of Selenium IDE v1.5.0 has lot of improvement over its preceding version. It has support for Firefox 9 and Select formatting for Webdriver binding in Java, python, c# which is really cool. Selenium IDE is really a good start for beginners, who think of doing some real automation and see it in action in just few clicks. Selenium IDE comes as a plugin for Firefox and looks something like this clip_image001 Using Selenium IDE one can easily
  • Add Test cases
  • Modify Test cases
  • Export Test cases in to some languages like C#, JAVA(JUnit & TestNG), Python,Ruby in both Webdriver and RC
  • Import Test cases
  • Check the Log details for recording and
  • Check the recording Action of course
Selenium IDE is pretty light weight and takes no resource of your machine and not even slow down your browser. The play back of Selenium is lightning fast and I would say faster than QTP. Lets start recording our first test and see how it works. I am going to record our favorite website and see how selenium tests it for us. Step 1 Let’s open the Selenium IDE from firefox using Toolsà Selenium IDE clip_image003 Step 2 I have just click the Learn via Blog image from the page and Selenium effortless recorded the action for me and it looks something like this clip_image005 As you could see in the screen shot above, the IDE has three columns
  • Command
  • Target
  • Value
Command in IDE is something like “Action” you are going to perform in the browser. As you could see above the first action it performed it “Open” the browser. Here the first action is “Open”. Similarly the next action it has performed is ClickAndWait which mean, click something and wait till it opens. Next is Target, here there is just a single “/” symbol, which means it’s going to open the Base URL which is specified in the Selenium IDE. Value is something, which you are going to pass in your application while recording, let’s say searching for some data from website. The field looks as one shown below. clip_image007 As you could see above, I have searched for “Code Snippet” in search field of website and this is nothing but the value I am passing into the application, hence value field came up in Selenium. You can change the value to whatever value you want. As that said, let’s try rerunning the same action and see how it works in action. Note: Make sure you select the “Open” as your first action in your test case before running, else your testcase will run from the place its selected. Step 3 Just click on the “Play current Test case” button , that’s it, Selenium will take care all of it automatically. One test gets executed, your Selenium IDE looks like this. clip_image009 As you could see the log tab, it shows all the execution steps it performed during playback. Verify the Text You could perform lot of other options using Selenium. Let’s say, if you would like to verify the Search it performed is really the one you have entered “Code Snippet”, you can verify the text by just right clicking the text to verify in browser, it will show you options as shown below. clip_image011 If you select the “Show All Available Commands” it will show you lots of command supported in selenium, which is really awesome. clip_image013 Exporting the recorded code to Junit 4 (Webdriver) Now if you think you want to export the code to Selenium, then go to Selenium Fileà Export Test Cases As à Junit 4 (WebDriver) clip_image015 Now the exported code looks something like this
package com.example.tests;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Code {
	private WebDriver driver;
	private String baseUrl;
	private StringBuffer verificationErrors = new StringBuffer();
	public void setUp() throws Exception {
		driver = new FirefoxDriver();
		baseUrl = "";
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

	public void testCode() throws Exception {
		driver.get(baseUrl + "/");
		driver.findElement(By.cssSelector("span > span > img")).click();
		driver.findElement(By.linkText("Selenium Codes")).click();
		driver.findElement(By.xpath("//input[@id='s' and @value='']")).clear();
		driver.findElement(By.xpath("//input[@id='s' and @value='']")).sendKeys("code snippet");

That’s it !!! Karthik KK

Post Author: Karthik kk

Leave a Reply

Your email address will not be published. Required fields are marked *