Unexpected window eventhandler activation
- 6 years ago
Hi,
> link the documentation about how to create eventhandlers.. I already read it.
Fine. This makes me think that setup actions have been done and done correctly.
TestComplete treats some window as unexpected one if this window blocks action to be done over some other window.
Windows that are considered to be unexpected are usually system or application modal ones that make it not possible to activate another window of the tested application until this modal window is closed.
Note, that window is considered to be unexpected only if it has blocked some action over another window of the same application. Otherwise there is no criterion to decide if the just opened window is unexpected or not.
The generic approach for unexpected windows:
-- Call .Activate() method for the window. Window activation (put on top of all other windows of the tested application) will fail if this window is overlapped by some other modal window and this will trigger OnUnexpected event;
-- Controls on the form do not have .Activate() method but they have .SetFocus() one.
Note, that if you do not perform activation/focusing actions over the form/control but manipulate it via its other methods/properties that do not perform activation, the OnUnexpected event will not be triggered even if the target window/control cannot get input focus. For example, this line of code will not trigger the OnUnexpected event because it operates directly against object's property:
myApp.LoginForm.UserName.Value = 'John';
> testapp.menuMain.Close();
When you close the tested application, the OnUnexpected event will not be triggered because as a rule you do not activate any other window. In this case you need to wait in a loop until the process of the tested application ends (within some reasonable timeout) and check if some window appears on thescreen and close it if it does. (Yes, you must know what windows might be shown on application close.)
Something like this (pseudocode):
do {
if (app.WaitChild('CrashWindow1', 500).Exists)
' handle CrashWindow1;
if (app.WaitChild('CrashWindow2', 500).Exists)
' handle CrashWindow2;
Delay(500);
} until app.Exists();