Forum Discussion

dhundley's avatar
dhundley
Regular Contributor
10 months ago
Solved

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-w...
  • dhundley's avatar
    dhundley
    10 months ago

    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!