Forum Discussion
- shankar_rCommunity Hero
Option#1:
Enable the Stop on Error option in the Tools > Current Project Properties.
Option #2:
Use Runner.Stop() method inside the GeneralEvents_OnLogError function.
- SushantNflOccasional Contributor
Thanks Shankar.
Well I actually have a different requirement.
I have a list of data for which the same set of actions needs to be performed.
Whenever an UI error occurs for one instance, I need to close the software -> Relaunch it -> then start the process for the next item in the list.
I am maintaining list index globally so thats not a problem.
I tried incrementing index in onlogerror method and called the main function again (although its not the correct approach) and runner.stop() after that.
index=0 def main(): global index list = ["A","b","c"] launchApplication() while index<len(list): performActions(list(index)) #this code will throw UI errors def GeneralEvents_OnLogError(Object Sender, EventArgs logParam): global index index = index + 1 closeApplication() main() Runner.Stop()
The issue here is although the error instance is skipped and the next set of items are executed, the code after executing main() (underlined) doesn't stop and goes back to the line where error came up first.
- shankar_rCommunity Hero
This can be a recursive call.
Instead of using OnlogError event handler, you try like below.
I'm not python/delphi scripter.
Pseudo:
index=0 def main(): global index list = ["A","b","c"] launchApplication() while index<len(list): if ! performActions(list(index)) #perfornActions should have return value as true or false #do the relaunch and increment