For handling UI errors, I am using GeneralEvents_OnLogError which again goes to the error line after executing its definition.
But I don't want it to return to the original error source.
Instead I want that the script execution should stop after execution of GeneralEvents_OnLogError is complete.
How can I achieve this?
Thanks in advance.
Enable the Stop on Error option in the Tools > Current Project Properties.
Use Runner.Stop() method inside the GeneralEvents_OnLogError function.
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.
This can be a recursive call.
Instead of using OnlogError event handler, you try like below.
I'm not python/delphi scripter.
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
Got your point but it won't help.
If onlogerror is removed and Stop on error is unchecked (which is definitely required to continue the script execution), all the statements in performActions will be executed even if error come up on some line.
This is very risky considering the fact that a previous step wasn't performed correctly.
I need something like continue which can be used to skip the next steps for that iteration and start the next iteration of the loop whenever there is an UI error.
You have control over performActions function, you will be able to decide when a failure comes, I would suggest making changes in performActions to solve your scenario.
Well python errors are well under control, but for UI errors, I was relying on GeneralEvents_OnLogError since Ui errors can either be controlled by stop on error setting or onlogerror method. Thats where I am stuck.
Anyways Thanks for your help. 🙂
If you have any other clue please let me know.