0

I have this error when I ran this test. For the previous test file, it ran perfectly.

@DataProvider(name = "login")
public Object[][] loginData() throws BiffException, IOException {
    Object[][] arrayObject = testDataXls.getExcelData(
            System.getProperty("user.dir") + "\\src\\test\\resources\\testdata\\Input_TestData.xls",
            this.getClass().getSimpleName());
    return arrayObject;
}

Here the getExcelData I used

public String[][] getExcelData(String fileName, String sheetName)
        throws BiffException, IOException {
    String[][] arrayExcelData = null;

    FileInputStream fs = new FileInputStream(fileName);
    Workbook wb = Workbook.getWorkbook(fs);
    Sheet sh = wb.getSheet(sheetName);

    int totalNoOfCols = sh.getColumns();
    int totalNoOfRows = sh.getRows();

    arrayExcelData = new String[totalNoOfRows - 1][totalNoOfCols];

    for (int i = 1; i < totalNoOfRows; i++) {

        for (int j = 0; j < totalNoOfCols; j++) {
            arrayExcelData[i - 1][j] = sh.getCell(j, i).getContents();
        }

    }
    return arrayExcelData;
}

I don't know why it didn't perform as the previous test file. And the error is highlighting on the Object[][] arrayObject = testDataXls.getExcelData(

Kimpertron
  • 19
  • 4

1 Answers1

0

Your testDataXls instance is probably null. I suggest you to run this test case in debug mode and put a breakpoint on that line. Then inspect the testDataXls instance.

Rajan Prasad
  • 1,582
  • 1
  • 16
  • 33
  • able to solve it. I use this method: Object[][] arrayObject = testDataXls.getExcelData("C:\\Users\\eclipse\\selenium\\src\\test\\resources\\testdata\\Input_TestData.xls", "AppScenarios"); – Kimpertron Mar 24 '20 at 04:40