I have the following code
private void execute_TestCase() throws Exception {
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). When calling the NullPointerException in getcelldata. But with same (13,6) pair it works fine at the bottom. Find below the getCellData code
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"";
}
}