Unexpected Window Event Handler
I’m trying to set up my OnUnexpectedWindow event handler. I am following the exact steps that are shown in the following smartbear video:
https://support.smartbear.com/testcomplete/videos/dealing-with-unexpected-pop-ups/
my handler is doing what it is supposed to do (clicking a Yes button on the unexpected window which closes the window) but the test is not continuing from that point like it does in the video. It still fails with an unexpected window error even though the unexpected window no longer exists.
I have this theory as to why it might be failing but don't know what i can do to resolve it (if it is in fact the case).
Here is a screenshot of how my application looks with the unexpected window centered on the screen. The larger window in the background is my application
The event handler has three parameters: Sender, Window and LogParams
If I put a Log.Message(Window.Name) statement in the event handler, it logs the name of the application in the background into the results log
rather than the little window in the middle (as can be seen in the object browser image below).
Why isn’t the the correct window name being passed into the Handler's Window parameter?
after much trial and error I think i may have stumbled upon a solution. Here is my event handler
i put some Log.Message statements in to show what's happening. When the Click action on the File | Exit menu is impeded because of the modal window the event hander is triggered. The If statement on line 17 checks to see if the unexpected window is a message popup box. If it is not, then it will assign the message popup box to the Window parameter and then click right in the middle of it to make it the active control on the screen. at that point i think it is going back and trying to Click File | Exit again. it is still impeding but the second time the event handler gets triggered the Window parameter is now equal to model window object and the Yes button is clicked. Here's the results log showing how this event handler was executed. The first window click was closing the Teller tab. The second window click in the red box is in the middle of the pop up during the first traversal of the event handler and then the button click is on the Yes button of the pop up and finally the File | Exit is clicked and the test case was successful. It's a bit of a roundabout way of doing it but it does seem to work.
still seems like the modal window should be sent to the event handler the first time but apparently it's not. I will hold off on marking this as the solution in case someone has a better suggestion for me. thanks!