Forum Discussion

shankar_r's avatar
shankar_r
Community Hero
7 years ago

Handle a window that comes anytime during execution

Hi All,

 

Scenario:

I'm running a test suite contains around 50 to 60 test cases using a data-driven framework. A window that can come anytime during the execution. When that window comes script should have ability to capture that window and then do some actions on the window. Then execution should get continue. 

 

UnExpected window event won't help in some scenarios like when i do validation in table,  when i'm not doing any actions. the same with OverLapping window.

 

When the window comes How we can identify anytime?????

5 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    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.

    • shankar_r's avatar
      shankar_r
      Community Hero

      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.

       

       

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Well... Usually, TestComplete can access properties of the invisible object that exists. So, if the main window still exists but is hidden when the additional window is opened (what was the reason for such design..?), what if you check whether or not main window is visible before any UI action (mouse, keyboard) and proceed appropriately ?

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    I actually have a potential situation where I need to do the same thing.  My best solution that I've come up with is to use Utils.Timers.  What I would do is set up a timer at the beginning of your test run, configure to trigger at a particular interval (say, once a second or something like that), and have the routine handle the window.  The problem with this is that if the window comes up between triggers, it could still interfere with script actions.

    • shankar_r's avatar
      shankar_r
      Community Hero

      Thanks tristaanogre for the input, It will work but in our case, execution time is 20+ Hrs.

       

      I'm guessing, this will play a role part of  performance stuff.

       

      Anyways, i will try it out.