我有以下代码
私人无效执行_TestCase()抛出异常{
int iTotalTestCases = ExcelUtils.getRowCount(Constants.Sheet_TestCases);
System.out.println("Total TC count" + iTotalTestCases);
**formname=ExcelUtils.getCellData(13, 6, Constants.Sheet_TestCases);**
System.out.println("F"+formname);
for(int iTestcase=1;iTestcase<iTotalTestCases;iTestcase++){
bResult = true;
sTestCaseID = ExcelUtils.getCellData(iTestcase, Constants.Col_TestCaseID, Constants.Sheet_TestCases);
sRunMode = ExcelUtils.getCellData(iTestcase, Constants.Col_RunMode,Constants.Sheet_TestCases);
if (sRunMode.equals("Yes")){
Log.startTestCase(sTestCaseID);
iTestStep = ExcelUtils.getRowContains(sTestCaseID, Constants.Col_TestCaseID, Constants.Sheet_TestSteps);
iTestLastStep = ExcelUtils.getTestStepsCount(Constants.Sheet_TestSteps, sTestCaseID, iTestStep);
bResult=true;
System.out.println("sTestCaseID"+ sTestCaseID);
System.out.println("iTestStep"+ iTestStep);
System.out.println("iTestLastStep"+ iTestLastStep);
for (;iTestStep<iTestLastStep;iTestStep++){
sActionKeyword = ExcelUtils.getCellData(iTestStep, Constants.Col_ActionKeyword,Constants.Sheet_TestSteps);
sPageObject = ExcelUtils.getCellData(iTestStep, Constants.Col_PageObject, Constants.Sheet_TestSteps);
sData = ExcelUtils.getCellData(iTestStep, Constants.Col_DataSet, Constants.Sheet_TestSteps);
execute_Actions();
if(bResult==false){
ExcelUtils.setCellData(Constants.KEYWORD_FAIL,iTestcase,Constants.Col_Result,Constants.Sheet_TestCases);
Log.endTestCase(sTestCaseID);
break;
}
}
if(bResult==true){
ExcelUtils.setCellData(Constants.KEYWORD_PASS,iTestcase,Constants.Col_Result,Constants.Sheet_TestCases);
Log.endTestCase(sTestCaseID);
}
}
}
}
formname=ExcelUtils.getCellData(13, 6, Constants.Sheet_TestCases)。在 getcelldata 中调用 NullPointerException 时。但是对于相同的 (13,6) 对,它在底部工作正常。在 getCellData 代码下方找到
public static String getCellData(int RowNum, int ColNum, String SheetName ) throws Exception{
try{
System.out.println("sheet"+SheetName);
ExcelWSheet = ExcelWBook.getSheet(SheetName);
System.out.println("Excelwsheet"+ExcelWSheet);
Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum);
System.out.println("test here2");
String CellData = Cell.getStringCellValue();
System.out.println("Celldata"+CellData);
return CellData;
}catch (Exception e){
System.out.println("Exception" + e);
Log.error("Class Utils | Method getCellData | Exception desc : "+e.getMessage());
DriverScript.bResult = true;
return"";
}
}