Forum Discussion
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.
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