Consider spreadsheet holds multiple combinations of inputs to be fed to test the application. The best practice here is to keep the data sheet in a common place, preferably in the source of current directory.
Following script designed using Jxl.jar file
public class DDT {
public Selenium selenium;
@Test
public void DataDrivenTesting()throws Exception {
FileInputStream fi=new FileInputStream("F:\PATH.xls");
Workbook w=Workbook.getWorkbook(fi);
Sheet s=w.getSheet(0);
selenium.open("http://www.google.com");
selenium.windowMaximize();
for (int i = 1; i < s.getRows(); i++)
{
//Read data from excel sheet
selenium.type("name=q",s.getCell(0,i).getContents());
selenium.click("btnG");
Thread.sleep(1000); }
}
}
Note:Below are should import to run above script
import java.io.FileInputStream;
import jxl.Sheet;
import jxl.Workbook;
import com.thoughtworks.selenium.*;
import org.testng.annotations.Test;
You have given only a few parts.
ReplyDeletePlease upload all major functions, so we can use them. Thanks a lot in advance.