I'm trying to consume data from an excel spreadsheet, but I always try to format the spreadsheet for text and number, and even then the error persists.
How do you arrange this?
I saw that a person resolved using this cell.setCellType(Cell.CELL_TYPE_STRING);
but I do not know where I should fit this snippet into my code.
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++){
String j_username = sheet.getRow(i).getCell(0).getStringCellValue();
String j_password = sheet.getRow(i).getCell(0).getStringCellValue();
searchbox.sendKeys(j_username);
searchbox2.sendKeys(j_password);
searchbox.submit();
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.MILLISECONDS);
}
workbook.close();
file.close();
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();