Ask a Question

Closing Window with Unexpected Window Handler is aborting entire test run

SOLVED
andrewa
Contributor

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);
}




4 REPLIES 4
Marsha_R
Champion Level 2

Am facing the same problem. Hope anyone here can help me too. Thanks in advance. Regards,

tristaanogre
Esteemed Contributor

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

That fixed the problem! Thanks!

cancel
Showing results for 
Search instead for 
Did you mean: