我有关键字驱动框架的代码,下面的代码包含 DriverScript类:
for (int iRow=1;iRow<=8;iRow++){
actionKeywords = new ActionKeywords();
method = actionKeywords.getClass().getMethods();
sActionKeyword = ExcelUtils.getCellData(iRow, Constants.Col_ActionKeyword);
sPageObject = ExcelUtils.getCellData(iRow, Constants.Col_PageObject);
execute_Actions();
}
ExcelUtils类:
public static String getCellData(int RowNum, int ColNum) throws Exception{
Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum);
String CellData = Cell.getStringCellValue();
return CellData;
}
执行此操作时显示错误:
Exception in thread "main" java.lang.NullPointerException
at utility.ExcelUtils.getCellData(ExcelUtils.java:33)
at ExecutionEngine.DriverScript.main(DriverScript.java:65)
答案 0 :(得分:0)
谢谢Eduard。某些列的单元格值为空(Null),这会导致错误。所以现在我把一些随机数据如(测试)放在里面,现在代码对我来说很好