Forum Discussion
Hi Dan,
> Is there a way to define which windows would be "unexpected"
The window is considered to be unexpected in TestComplete (with the triggering of the OnUnexpectedWindow event) if this window blocks UI action on some other window object that test code tries to perform.
As a rule, unexpected windows are detected when test code tries to .Click() or .Activate() some object and this action is blocked by some other window.
For example, if test code entered wrong data into a form field and this caused display of modal warning window and test code tries then to click the OK button on a form, the click will be blocked because of the modal window and OnUnexpectedWindow event will be triggered.
On the other hand, if test code explicitly checks modal warning window existence and handles the window if it exists, then OnUnexpectedWindow will not be triggered.
Also, for the above example, if after the modal warning window was displayed test code assigns a value to some other field on the form via the .SetText() method, the OnUnexpectedWindow event will not be triggered either because .SetText() method does not interact with UI but makes assignment via non-GUI function call.
- loridee5 years agoNew Contributor
Hi Alex,
Thanks for your reply. I work with the OP who is off today so I am going to answer in his place to help us get to the bottom of this :-).
So, your example of " if test code entered wrong data into a form field and this caused display of modal warning window and test code tries then to click the OK button on a form, the click will be blocked because of the modal window" is exactly what is happening. You say however that "an OnUnexpectedWindow event will be triggered". Ok, so that is following with the documentation we see in a link like this: https://support.smartbear.com/testcomplete/docs/testing-with/running/handling-errors/unexpected-windows.html where it says that TC waits until the auto-wait timeout period expires, then fires OnUnexpectedWindow.
What we are really curious about is why step 3 on that page is not happening, where if the window is not closed by the handler, then TC goes through a series of steps to close the modal - pressing ESC key, pressing ENTER key, sending close command to the window. We can't seem to get this behaviour to happen - right now if a modal pops up and we do not have a handler for it it is just failing our test because TC is never closing the window. We have an understanding from the docs that TC can and will handle these modals without us having to specifically code for them....?
We have used TestComplete for 6 or 7 years now and are on our second iteration of creating tests for our application. We cannot now, nor have we been able to in the past, get the automatic handling of unexpected windows to happen. Our previous GUI test code we coded some special handling for all unexpecteds, but this time around would like to see if we can get TC to handle it and save us some of the work involved.
- AlexKaras5 years agoChampion Level 3
Hi,
> why step 3 on that page is not happening
Have you checked settings mentioned for the first two paragraphs of step 3?
According to the documentation, TestComplete tries to close unexpected window only in the case when it is not commanded to stop test run. If, according to settings, test run must be stopped, then TestComplete does not try to close the unexpected window.
- ddguy5 years agoOccasional Contributor
Hi Alex,
All of our error handling settings tell TestComplete to Continue running on error, on object recognition error, and on warning.
I have attached an image of our TC settings.
Related Content
- 5 years ago
- 12 years ago
- 5 years ago
- 4 years ago
Recent Discussions
- 10 hours ago