I am trying to develop a data driven Selenium automation framework in Java. I have written code to read input test data from excel sheet. The excel sheet contains two columns - Username and Password. I read the excel data using the following code.
String testData;
for(int j=1;j<currentRow.getPhysicalNumberOfCells();j++){
if(currentRow.getCell(j)!==null)
{
if(currentRow.getCell(j).getCellType()==Cell.CELL_TYPE_BOOLEAN){
testData=Boolean.toString(currentRow.getCell(j).getBooleanCellValue());
}
if(currentRow.getCell(j).getCellType()==Cell.CELL_TYPE_NUMERIC){
testData=Double.toString(currentRow.getCell(j).getNumericCellValue());
}
if(currentRow.getCell(j).getCellType()==Cell.CELL_TYPE_STRING){
testData=currentRow.getCell(j).getStringValue();
}
}
}
The problem is that if the password is 123, the above code will return the value 123.0 and hence the test case fails. I cannot remove the decimal point since if the actual password is 123.0, it would return the result 123. How can I read the excel data as it is given in the cell?