Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Selenium is entering 9.888888888E9 as phone number after getting it from excel

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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();
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading