Forum Discussion

pichumani's avatar
pichumani
New Contributor
28 days ago

Unexpected Window event is fired only once.

I am testing WPF application. And i have configured a UnexpectedWindow event via Events--> EventControl.  The Event is fired only for the first time an unexpected window appears.

For the subsequent unexpected windows, The Event is not fired

 

For reference, The Sequence is as follows:

1.) some test steps

2.) unwanted dialog appears -> event fired and handled properly

3.) some test steps 

4.) unwanted window appears -> no events fired, timeout and error.

 


am i missing something ? should configure something so that event is fired every time ?

 

 

TestComplete Version: 15.80.1.7 x64

6 Replies

  • Hassan_Ballan's avatar
    Hassan_Ballan
    Icon for Champion Level 3 rankChampion Level 3

    In TestComplete this usually happens for one of these reasons:

    Most commonly (especially with WPF apps), the dialog isn’t actually being recreated the second time — it’s just being hidden and shown again. If the window object never gets destroyed, TestComplete doesn’t treat it as a “new” unexpected window, so the event won’t fire again. You can confirm this in Object Browser by checking whether the window truly disappears from the hierarchy or just toggles Visible, rather than being removed completely.

    Other things worth checking:

    • Make sure the event is still enabled under Project → Properties → Events
    • Verify the second dialog really matches the same process/class/caption (sometimes the caption text, parent, or index changes slightly)
    • Ensure it wasn’t added to Name Mapping after the first run. If it’s mapped (or falls under a mapped parent), TestComplete may now treat it as a known object instead of an unexpected one, so the event won’t trigger
    • Increase the Auto-wait timeout in case the test step fails before the event handler has a chance to execute

    If this resolves your scenario, marking it as the solution helps future readers find it quickly.

    • pichumani's avatar
      pichumani
      New Contributor

      Hello Hassan Ballan,

       

      Thanks for the response. I have checked and tried all the options you have mentined. I came here after exchauting all the options i have. 

       

      But today when i changed to this option, The UnexpectedWindow event seems to be fired all the time. 

      Tools-->Current Project Properties--> On error: Stop and rerun current item

      Not sure why it happens. But Intuitively speaking, even when this Option is set to "Stop project/Stop current item", the event should be triggered.

       

      I will keep you posted if there are any irregular firing of events or no firing of events occur again

       

      Regards

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    The unexpected dialog that appears, is it an assertion or an error dialog coming from the actual application? Does it always appear after performing specific actions?

    • pichumani's avatar
      pichumani
      New Contributor

      It is an error dialog coming from the actual application. It appears only when certain conditions fail. The event was not fired all the time during the error(condition failure) case. 

      • rraghvani's avatar
        rraghvani
        Icon for Champion Level 3 rankChampion Level 3

        Based on past experience, if the application throws an unexpected error message, I won’t automate it. This is mainly because the next steps may not produce the expected results due to the previous error. However, if the error message consistently appears after performing certain actions, then I can easily handle it without using event handlers.

        Regardless of the project settings, the event handler should be triggered, provided it meets the requirements. More information can be found in Handling Unexpected Windows.