Forum Discussion
Thanks a lot Robert for your detailed reply. :)
I have a further query for the solution that you have suggested.
In performTask method, if the error occurs due to some unexpected window, or any other issue where UI objects are involved, will the exception handling of python handle it?
I believe the Python exception handling can only handle python errors and not the UI window errors.
I may be completely wrong as I am new to Test Complete.
Kindly post your thoughts on this.
You are right, try...except will not handle UI errors. I'd suggest you another solution:
def main(): while indexValue<len(list): launchApplication() performTask(list(indexValue)) indexValue = indexValue + 1 Log.Message("Process Completed") def GeneralEvents_OnLogError(Sender, LogParams): CloseOpenApplcaition() def launchApplication(): if(not isAppRunning()): startApp()
The main idea is that you call launchApp() function in every iteration of the while loop and start the app only if it is not started yet. In the OnLogError event handler you just close your app
- SushantNfl7 years agoOccasional Contributor
Thanks for your reply.
But I am not sure if this will work
The requirement is to run performTask method for every item of the list.
I believe in your suggestion,the script execution would stop once any error occurs for an item(i.e. once the code enters OnLogError method).
But instead of stopping the execution, I need to continue the process with the next item in the list.
I have been able to achieve this with my code(posted in the question) but the issue that I am facing is that the GeneralEvents_OnLogError is getting executed recursively even after completing the process for all the items.
Kindly guide me how can I handle this.
- karkadil7 years agoValued Contributor
You need to uncheck the option
Tools - Current Project Properties - Playback - Stop on Error
and then my solution will work for you.
- SushantNfl7 years agoOccasional Contributor
karkadil: The issue here is that the error occurs in performTask method after which generalevents_onlogerror is invoked and the control goes back to the step where error occured (which again causes failure since the application is closed by the onlogerror method).
I need to close then reopen the application and start the same (performTask) for the next item in the list.
Any suggestions, how can I achieve this?
Related Content
- 13 years ago