Ask a Question

Issue with Data-Driven Loop, script is not gracefully exiting on error

Occasional Contributor

Issue with Data-Driven Loop, script is not gracefully exiting on error

We have a requirement to create multiple accounts. All the test data are being passed from an excel sheet, for that a data-driven loop is used. 

Each row in the Excel sheet is treated as a different test case.


Issue Detail:-

If one test case failed due to test data or any other issue, the script should mark that particular test case( row of an excel sheet) as failed and should pick the next row for execution. The problem is here that if the Playback setting is set as Continue on error, then in this case script is not exiting that case and continuing with the next steps.

If we set "Stop current item" in the playback setting, its moves to the next test case but the script is not entering any values in the next case and getting failed due to the "Operation interrupted by the user" error, and all the further test cases also got failed due to similar issues.


Please suggest a way to resolve this issue. Thanks


Sample Code for reference


code is similar to below



while not dataVar.EOF():







   except Exception as e:

      Log.error("Error Occured"+str(e))




Champion Level 2

Do you expect all of this data to work or do you have some planned failures?

Occasional Contributor

Hi Marsha_R,


Thanks for looking into this issue.

We are expecting all data to be worked however during execution some may fail in validation. In a failure scenario, our expectation is to fail that particular test case and pick the next in the row.




I don't know your syntax but it sounds like your Try and Next are working ok together, but when you hit the Exception, it doesn't know how to go on. I would try putting another Next under the Exception and see what happens.






Occasional Contributor


I tried to use another Next in except block but no luck.

I've uploaded the code and test data file for your reference. Please change the TestDataPath variable value.

There are 3 rows in the test data file, each is treated as a  different Test case. 

Thank you for the information.  


For security reasons, I won't open that .zip file.  If you'd like to post a screenshot, I'd be happy to look further.

Champion Level 2

You are using the FindElement() method which either returns the Object that matches the search condition or returns None if condition not matched. FindElement() does not throw an error.



Occasional Contributor

Screenshots attached for your reference.

Main Code.pngProject Property.pngTestData.png


Hi @diwakar_sh12 ,


I am not that proficient with python, but you might want to put the try/except block inside of the while loop, that way it can continue with the next entry if an error is raised. I'm not certain of the exact syntax/format, but something like this might work:


  while not ddv.EOF
    aqTestCase.Begin("Test Case" + ddv.Value[0]);
      Log.Error("Error Occured")


I hope this helps.

Occasional Contributor

Hi Chris,


Thanks for looking into this issue. Actually, I've already tried that approach however no luck. What is happening here, if there are 10 objects on a page, and an error occurred at the second object then the script marks the step as a failure but at the same time it continues to perform the action on other objects on the page, it should skip that iteration completely and pick another in a loop. 


If you have any other solution to achieve this please let me know, I'll tweak my code accordingly.

Showing results for 
Search instead for 
Did you mean: