I\'m trying to consume data from a spreadsheet in Excel, but always of this error, already tried formatting the worksheet to text and number and still the error persists.
This will work:
WebElement searchbox = driver.findElement(By.name("j_username"));
WebElement searchbox2 = driver.findElement(By.name("j_password"));
try {
FileInputStream file = new FileInputStream(new File("C:\\paulo.xls"));
HSSFWorkbook workbook = new HSSFWorkbook(file);
HSSFSheet sheet = workbook.getSheetAt(0);
for (int i=1; i <= sheet.getLastRowNum(); i++){
HSSFCell j_username = sheet.getRow(i).getCell(0)
HSSFCell j_password = sheet.getRow(i).getCell(0)
//Setting the Cell type as String
j_username.setCellType(j_username.CELL_TYPE_STRING)
j_password.setCellType(j_password.CELL_TYPE_STRING)
searchbox.sendKeys(j_username.toString());
searchbox2.sendKeys(j_password.toString());
searchbox.submit();
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.MILLISECONDS);
}
workbook.close();
file.close();
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}