}MyActualSeleniumCode: public class Sample {
private WebDriver driver;
int xRows, xCols;
@Before
public void setUp() throws Exception {
}
@Test
public void CustInfo() throws Exception {
// String vURL,vEmail,vPswd,vCnfmPswd;
// int vCustAccNum;
// int vZipCode;
long iWait;
int Size;
// Read Test Data from Excel
String xlPath = "C:\\SCE docs\\Automation\\InputData_Registration.xls";
CustomerData[] customerData = getExcelData(xlPath,"AccountHolderRegistration");
System.setProperty("webdriver.chrome.driver", "c:\\chromedriver.exe");
driver = new ChromeDriver();
// driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
iWait=3000;
for (int k=1; k<xRows; k++)
{
driver.navigate().to(vURL);
driver.findElement(By.linkText("Register")).click();
driver.findElement(By.id("emailInputBox_input")).clear();
driver.findElement(By.id("emailInputBox_input")).sendKeys(customerData.getvEmail());
driver.findElement(By.id("pwdInputBox_input")).clear();
driver.findElement(By.id("pwdInputBox_input")).sendKeys(vPswd);
driver.findElement(By.id("confirmpwd_input")).clear();
driver.findElement(By.id("confirmpwd_input")).sendKeys(vCnfmPswd);
driver.findElement(By.id("radio1")).click();
driver.findElement(By.id("accountInputBox_input")).sendKeys(Integer.toString(vCustAccNum));
driver.findElement(By.id("accountInputBox_input")).clear();
driver.findElement(By.id("zipcodeBox_input")).sendKeys(Integer.toString(vZipCode));
driver.findElement(By.id("zipcodeBox_input")).clear();
driver.findElement(By.id("terms3")).click();
}
}
public CustomerData[] getExcelData(String Path, String shtName)
throws Exception {
File myxl = new File(Path);
FileInputStream fi = new FileInputStream(myxl);
HSSFWorkbook myWB = new HSSFWorkbook(fi);
HSSFSheet mySheet = myWB.getSheet(shtName);
xRows = mySheet.getLastRowNum() + 1;
xCols = mySheet.getRow(0).getLastCellNum();
CustomerData[] customerDataList = new CustomerData[xRows];
for (int i = 1; i < xRows; i++) {
HSSFRow row = mySheet.getRow(i);
CustomerData customerDetails = new CustomerData();
customerDetails.setvURL(row.getCell(1).getStringCellValue());
customerDetails.setvEmail(row.getCell(2).getStringCellValue());
customerDetails.setvPswd(row.getCell(3).getStringCellValue());
customerDetails.setvCnfmPswd(row.getCell(4).getStringCellValue());
// System.out.println("value "+row.getCell(0));
customerDetails.setvCustAccNum((int) row.getCell(5).getNumericCellValue());
customerDetails.setvZipCode((int) row.getCell(6).getNumericCellValue());
customerDataList[i] = customerDetails;
System.out.println("row 2: "+(row.getCell(5)));
}
//System.out.println (" After the loop the Excel data" + customerDataList);
return customerDataList;
}
}