Untill now I catch errors with the OnError event.
But I need to perform a method on "OnError", a method that is in the script.
Please consider this code :
procedure TestErrorException; begin try // Goes to OnError event : not ok Aliases.MyExe.FormCptReciproque.PanelBas.XPBitBtnSaisieEcr.Click(); //Goes to the finally : ok a_variable:= 0; //Goes to the finally : ok raise('I raise an exception'); finally Log.Message('I need to go there in every case'); end; end;
I try to make for every case the procedure going to the finally. It works well in the case 2 and 3, but in case of not finding an object, it raises an error that trigger the OnError event.
But I still need to be into the call method, before the event to performs some steps.
Any help would be greatly appreciated
If it's on intercepting not found error you can modify your onError event.
I suggest you to look at this thread.
As for me to fully control the error flow I use a mix between a global variable storing the last error object (null if no error), the try..catch syntax and the onError event.
Un sourire et ça repart
Your code should pass through the finally statement for all three cases. It might terminate immediately if you have your project's/test item's setting to stop on error, but even in this case I would expect finally statement to execute and I would consider this behavior as DelphiScript's flaw and contact Support (https://support.smartbear.com/message/?prod=TestComplete) for their confirmation (and, hopefully, fix).
Thank you for replying,
In the OnLogError I had a Runner.Stop(True).
I understand that with this statement TC would stop and not go to the finally.
But I tried to remove it, and the main procedure just continues.
I tried to put a "raise" in OnLogError and the main procedure still continues without going instantly to the finally.
I wrote to the support...
> I tried to put a "raise" in OnLogError and the main procedure still continues without going instantly to the finally.
I have a strong feeling that several years ago there was a breaking change in DelphiScript engine (not sure was it for purpose or not) that unhandled exception thrown in some called script unit stopped to be traced back to the caller parent one that contains exception handling structures. This is how DelphiScript functioned initially for a lot of years.
I would really hope that guys will be able to correct this behavior while working on your case.
@m_essaid I see you opened a support ticket and the investigation there started. We would really appreciate it if you posted the solution you get from support here, thank you!
Get properties of a web page element
Compare images using the Region Checkpoint
Compare HTML table with Excel file and correct data in Excel file
How to execute remote test and obtain results via Test Runner REST API