What is the correct way to identify the unexpected window?
- 5 years ago
Hi,
To make it second to what was said by tphillips :
By definition, the unexpected window in TestComplete is the window that blocks user input and that is not referenced in test code.
If the window fits the above criteria, the OnUnexpectedWindow event will be triggered.
Note, that in order to be treated as unexpected, the window must block user input, i.e. to be system- or application modal and prevent activation of the window/control that test code tries to interact with.
So, in most cases, the OnUnexpectedWindow event is triggered by the .Activate, .Focus, .Click and .Keys methods and the most reliable way to detect unexpected window is to call .Activate or .Focus methods before trying to .Click or .Keys the window or control respectively for desktop applications.
Note, that if your test code does not interact with the application via GUI but uses direct assignments (e.g. via the .SetText method) the OnUnexpectedWindow will not be triggered because nothing prevents the target control to be interacted with.
If your test code explicitly waits if the modal window exists and processes it if it does, then, as it was said by tphillips, this window will not be considered to be unexpected and the OnUnexpectedWindow event will not be triggered.