GeneralEvents_OnUnexpectedWindow not invoked?
Hi, I seem to have some problem with unexpected window handling—in short, TC does not invoke my GeneralEvents_OnUnexpectedWindow event handler.
I have included a screenshot showing part of my keyword test, and here's what happening:
- Steps before the green mark 1 perform a click action on a button to open a (modal) window.
- Since opening the window includes some preparational steps of greatly varied length, I've added an If Object statement to wait for the text field I want to type in.
- This is just a message of debugging purpose, confirming test execution passes step 2.
- When performing this step, I receive a The object does not exist error. Note that this step is targeted at the very same object the existence of which is checked in step 2.
Since the message in step 3 appears in the test log, and step 4 generates an error, the unexpected window must be opened after step 3. I have a GeneralEvents_OnUnexpectedWindow event handler which closes the window, however this event handler is not called at all (no breakpoints are hit in it, no the log message included in the first line of the event handler's body displays in the log).
When I first read about handling unexpected windows in TC, I thought this is a very typical situation when it should work so that I can close the window.
Can you help me what may I do wrong and how to fix it to have my event handler invoked?
Hi,
The OnUnexpectedWindow event is triggered only when TestComplete tries to perform some action over the tested application and this action is blocked by the modal window. That is, if your test code tries to .Activate, or .Click, or .Keys over some tested object and this is blocked by some other modal window, the OnUnexpectedWindow event will be triggered.
Your code does not perform any UI-related actions (.SetText calls internal methods unlike the mentioned .Keys method) and thus the OnUnexpectedWindow is not triggered.