Excel Data Driven issue

Dear All, I am struck in a unique problem.

both codes  to execute the xlsx sheet works fine as long as each test step iteration results in a true condition, but once a step fails, it encounters with closing the browser(the second code  is   related to teststep status), is it possible to tune this code, so that it iterates through remaining all rows in the test case. (please no softassert kind of suggestions. I want to iterate all rows irrespective of any kind of test results till the end of the data iteration from the excel sheet.

thanks,
Sunrise

CODE_1
public void execute_TestCase() throws Exception {
int iTotalTestCases = ExcelUtils.getRowCount(Constants.Sheet_TestCases);
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;
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);
}
}
//
else if (sRunMode.equals(“No”)){
ExcelUtils.setCellData(Constants.KEYWORD_SKIP,iTestcase,Constants.Col_Result,Constants.Sheet_TestCases);
Log.endTestCase(sTestCaseID);
break;
//
}
}
}   

CODE_2

public  void execute_Actions() throws Exception {

for(int i=0;i<method.length;i++){

if(method[i].getName().equals(sActionKeyword)){
method[i].invoke(actionKeywords,sPageObject, sData);
if(bResult==true){
ExcelUtils.setCellData(Constants.KEYWORD_PASS, iTestStep, Constants.Col_TestStepResult, Constants.Sheet_TestSteps);

break;
}else  {

ExcelUtils.setCellData(Constants.KEYWORD_FAIL, iTestStep, Constants.Col_TestStepResult, Constants.Sheet_TestSteps);

break;
}

}
}
}

Add Comment
2 Answer(s)

You need to handle errors in method which you are calling.  Because those methods are returning errors ,  java is coming out of main method.
alternatively you can use try catch in above code.

rohitn Train Answered on May 11, 2015.
Add Comment

I have same situation where in my excel I have 4 rows test data,
when first row test data are failed, the remaining three rows will be failed.
Is this default behavior in Selenium or somethings wrong in my code?

nexuschristo Train Answered on May 12, 2015.
Add Comment

Your Answer

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