Issue
I have name, number, email etc in my excel which I am retrieving using the below code
Phone number in excel is 9888888888
v=wb.getSheet(sheet).getRow(r).getCell(c).toString();
but when I run my script to enter the data, selenium is entering 9.888888888E9.
I have tried formatting the cell in excel to "Text", "Number" but it has not worked.
How do I get it to enter the number as is in the excel?
Solution
Seleniun sendKeys()
doesn't have any function to convert the text. It just passes the values into destination. You need to change the method of getting value from excel. Please try below possible solutions,
v=wb.getSheet(sheet).getRow(r).getCell(c).getStringCellValue();
or
v=wb.getSheet(sheet).getRow(r).getCell(c).getRawValue();
or
if (wb.getSheet(sheet).getRow(r).getCell(c).getCellType() == Cell.CELL_TYPE_NUMERIC) {
v = NumberToTextConverter.toText(wb.getSheet(sheet).getRow(r).getCell(c).getNumericCellValue());
} else if (wb.getSheet(sheet).getRow(r).getCell(c).getCellType() == Cell.CELL_TYPE_STRING) {
v = wb.getSheet(sheet).getRow(r).getCell(c).getStringCellValue();
}
Answered By - Nandan A
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.