Closing Window with Unexpected Window Handler is aborting entire test run
So I have a suite of Windows tests. I've been having an error show up in the application. I want to be able to close it and fail the currently running keyword test and then continue on with the rest of the suite.
I was under the impression that if I wrote an OnUnexpectedWindow function and closed the window, Test Complete wouldn't abort the entire test run. My code is closing the window, yet the entire suite run gets stopped.
Do I need to alter my playback settings at all? Is it something else I'm doing wrong? Is the documentation about the OnUnexpectedWindow wrong?
I've attached a picture of the last few lines of the log, my playback settings, and the event handler settings. The following is my event handler code:
//USEUNIT CommonScripts function GeneralEvents_OnLogError(Sender, LogParams) { if (LogParams.MessageText == 'The operation cannot be performed, because the user session is locked.' || LogParams.MessageText == 'The operation cannot be performed, because the user session is disconnected.') { BuiltIn.ShowMessage ('Screen is locked. Perform the last action manually then continue test execution ...'); Runner.Pause (); LogParams.Locked = true; } else { Runner.Stop(true); } } /* if (LogParams.MessageText == 'The operation can not be performed, because the user session is locked.') { Log.Warning (LogParams.MessageText, LogParams.AdditionalText); BuiltIn.ShowMessage ('Screen is locked. Perform the last action manually then continue test execution ...'); Runner.Pause (); LogParams.Locked = true; } */ function GeneralEvents_OnUnexpectedWindow(Sender, Window, LogParams) { //BuiltIn.ShowMessage('Unexpected window detected. Please note any stack traces. Do not close the window. Continue Test Complete'); //Runner.Pause(); LogParams.Locked = true; CommonScripts.logWarningErrorWithStackAndPicture(LogParams.MessageText); Window.Close(); //Log.Error(LogParams.MessageText); //Runner.Stop(true); }
You have the "stop execution" flag checked on the On Unexpected Window portion of your engine setup. Turn that off.
That is still processed on an unexpected window. The event handler executes first when the event is triggered. Then, after the handler does it's thing, it will continue with what's indicated. If you don't want the test run to halt, just turn off that flag.