java.lang.NullPointerException

When i trying to read the data from excel sheet and if that column is blank then webdriver throwing the error “java.lang.NullPointerException”.
So how to handle this error whenever column has no data?

Default Asked on December 31, 2014 in Selenium WebDriver.
Add Comment
  • 2 Answer(s)

    Hi onimje,

    You would have something like this to address a cell in your code.

    if this codition comes out to be true you will get a null pointer else you can perform what ever action you want on  the cell.

    Thanks
    Virender

    Professor Answered on December 31, 2014.
    Add Comment

    OK…I solved it using try catch block…
    try {
    Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum);
    String CellData = Cell.getStringCellValue();
    return CellData;
    } catch (Exception e) {
    return “”;
    }

    Thanks for your reply!!!

    Default Answered on December 31, 2014.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.