Favourite Quote

Every artist was first an amateur. - Ralph Waldo Emerson The more difficulties one has to encounter, within and without, the more significant and the higher in inspiration his life will be. - Horace Bushnell

Wednesday, November 10, 2010

DataDriven Testing using Selenium - java

I am using excel for data driven testing.

public void login()
{
String uName = username;
String pWord = password;
try
{
FileInputStream fi = new FileInputStream ("C:\\Selenium\\datainput\\webservices.xls");
Workbook wbk = Workbook.getWorkbook(fi);
Sheet sht = wbk.getSheet("Credentials");
for(int rowCount=1;rowCount<=sht.getRows();rowCount++)
{
uName = sht.getCell(1,rowCount).getContents();
pWord = sht.getCell(2, rowCount).getContents();
objSelenium.type("xpath=//input[@id='j_username']", uName);
selenium.wait(Constants.MAX_WAIT_TIME_MS);
objSelenium.type("xpath=//input[@id='j_password']", pWord);
selenium.wait(Constants.MAX_WAIT_TIME_MS);
}
}catch(Exception e)
{
e.printStackTrace();
}
} automationwithselenium.blogspot.com-Google pagerank and Worth

No comments:

Post a Comment