Forum Discussion

joaobc's avatar
joaobc
Occasional Contributor
4 years ago
Solved

What is the correct way to identify the unexpected window?

In my application where I build my automated tests, several unexpected windows appear (error window, window to confirm by clicking OK, window to decide to click yes or no), I would like to gradually ...
  • AlexKaras's avatar
    4 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.