Context: Null pointer exception thrown when checking the length of blank excel cell.
Please help to fix the exception.
int lastRowNum = sh.getLastRowNum();
for (int i = 1; i < (lastRowNum+1); i++) {
Row row = sh.getRow(i);
System.out.println(i);
// Null pointer exception throws for below if condition
if (row.getCell(0).toString().length() == 0) {
actions.operations(objectRepository, row.getCell(1).toString(), row.getCell(2).toString(), row.getCell(3).toString(), row.getCell(4).toString());
}
else {
System.out.println("Test Case: " + row.getCell(0).toString() + " Started");
}
}