Forum Discussion
Hi Shankar,
Personally I would stick to OnUnexpectedWindow event. You may have additional details for your use case that will invalidate this approach, but my current reasons are like this:
a) Generally, it is a good practice to call .Activate() or .SetFocus() methods before using the mouse or .Keys() method. If the target window/control cannot be activated because of been blocked by some modal window, this will trigger OnUnexpectedWindow event and you will be able to process the blocking window without any performance penalties due to constant check whether or not the blocking window exists;
b) If the window of your interest is not a blocking one then this means that it will not block user from doing the job, the user is not forced to close it before he/she can continue to work and, depending on implementation, the window may even appear to be behind the application/form and be noticed when the task is done. In this case it may be enough to check for the window presence before and after the test does its job.
Thanks AlexKaras for the inputs,
In my case, AUT will be invisible during that window comes.
I tried use SetFocus() or Activate() method but the new window is not considering as unexpected window.
Log will just saying the your Main window is invisible thus can't be activated.