Forum Discussion
Verify your Project Settings for Playback is correctly setup - there's options for Error Handling and On Unexpected Window.
Also, since you are closing the tab, is it really considered to be an unexpected window, as you are being prompted "Are you sure you want close the Teller?" ?
- dhundley23 days agoRegular Contributor
these are the playback settings. while the On Error is set to Stop Current Item, the On unexpected window's Stop Execution is not checked so i would think that means that if the unexpected window is handled that it should not be considered an error and continue running.
as for the example being an expected window, you are correct, i know that this particular message box named Window("#32770", "CSI NuPoint", 1) will always appear when the Teller tab is closed and i will be automating the click of its Yes button but there are other types of these messages that will occasionally appear that have other messages such as "object reference not set to the instance of an object" or the extremely vague "Unhandled error". Quite often, if i click their OK or Yes buttons the test case will proceed and finish successfully. but i can't know when those message boxes are going to pop up so i'm trying to develop my event handler using the same type of box that i can control. inside the handler i will intercept the unexpected pop ups, issue a warning message in the log and, perhaps, even send an email to a developer with a picture of the pop up, the time, test case and location where it occurred and even attached a zip file containing the trace logs, but it will then click the appropriate button to allow it to continue running if the error is not fatal.
so, the question remains, why doesn't the Window parameter contain the name of the actual unexpected window in my scenario? The smartbear website
https://support.smartbear.com/testcomplete/docs/testing-with/running/handling-errors/unexpected-windows.html#Remarksshows the following information. By my having disabled the statements in my keyword test that click the Yes button, the next sequential automated step is to "Click" on the File|Exit menu selection (which can be seen in the upper left of the first image i posted yesterday). Since the unexpected window is modal it is what is "impeding" the Click action from occurring and, thereby, triggering the OnUnexpectedWindow event. But, as i said, my event handler is successfully closing the unexpected window by clicking the Yes button which, in turn, closes the Teller tab. IOW, it has satisfied step #3 at the bottom of the image below. So why isn't the automation resuming at that point to click File|Exit?
- dhundley23 days agoRegular Contributor
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!
- rraghvani23 days agoChampion Level 3
I no longer use event handlers in my automation, because I came across some weird behaviours, which I couldn't resolve at the time.
I'm not sure if the Else part is required, but your coding should work i.e. just perform btnYes.ClickButton();
Also, do try btnYes.Click(); to see if that makes any difference.
Related Content
- 11 years ago
- 7 years ago
Recent Discussions
- 7 hours ago
- 7 days ago
- 10 days ago