Saturday 9 March 2013

Record & Export Test Case(s)

Using Selenium IDE lets start recording our first test case
Navigate to your website and open up Selenium IDE 
lets use http://www.google.com for our example


Now minimise Selenium IDE window/popup that has opened.

Lets do a google search for "WebDriver API" and click on the search button
  

Restore the Selenium IDE window/popup  




Now export the test case and save as a suitable name.
I exported it as Java / JUnit 4 / WebDriver


Close Selenium IDE window/popup ignoring the following message


You should have a java file generated that contains the following code 
Please note I saved my exported test case as test1

package com.example.tests;

import com.thoughtworks.selenium.*;
import org.testng.annotations.*;
import static org.testng.Assert.*;
import java.util.regex.Pattern;

public class test1 extends SeleneseTestNgHelper {
 @Test public void testTest1() throws Exception {
  selenium.open("/");
  selenium.type("id=gbqfq", "WebDriver API");
  selenium.click("id=gbqfb");
 }
}





No comments:

Post a Comment