Forum Discussion

sameerjade's avatar
sameerjade
Frequent Contributor
8 years ago

Want to wait until a specific window appears; getting an error

Hello All,

 

I am trying to use the WaitWindow method to delay my script infinitely until a window displays. I am doing an update process in my application. When the update completes, I get a window which says 'update complete'. I want to wait till this window appears.

 

My script says:

 

var dlg = Aliases.update_complete_window_object_name;

dlg.WaitWindow("abc", "Update Complete", -1, -1);

 

The problem is that my script is failing because it is looking for this window even before my update is finished and hence fails to find the 'update complete' window. How can I make it not fail in this case and just wait for the window to appear?

 

Thank you,

 

Sameer

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    If I understand what I'm seeing, the window you're waiting for is what you have represented by "Aliases.update_complete_window_object_name". This explains your problem because when you assign the variable, it's trying to assign the window which, as you said, doesn't exist.  If that's the window that you want to wait for, I'd write the code like this

     

    var dlg = Aliases.WaitAliasChild('update_complete_window_object_name', 120000);
    if (!dlg.Exists){
        Log.Error('The upload window did not appear within 2 minutes');
    }

    See, WaitWindow needs to be called on the parent object of the window that you're waiting for.  However, in your case, the object is actually an Aliased object so I opted to use WaitAliasChild and set the max wait time to 2 minutes.

     

    The "Aliases" object doesn't have the WaitWindow method... so, in that case, if you still want to use WaitWindow, I'd go with something like

     

    var dlg = Sys.Process('MyApp').WaitWindow('abc','Update Complete', -1, -1)

     

     

    • sameerjade's avatar
      sameerjade
      Frequent Contributor

      Thank you Robert for your reply.

       

      When I used the following code, I get an error :  "JScript runtime error..the aliases object does not have a child with the name 'update_complete_window_object_name' ".

       

      var dlg = Aliases.WaitAliasChild('update_complete_window_object_name', 120000);
      if (!dlg.Exists){
          Log.Error('The upload window did not appear within 2 minutes');
      }

      About this, using this I can apply WaitWindow but I still run into the same problem i.e. it's trying to assign to variable dlg, the window which does not exist. But I suppose that is expected behavior.

       

      var dlg = Sys.Process('MyApp').WaitWindow('abc','Update Complete', -1, -1)

       

       

      Thanks,

      Sameer

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Not necessasrily.  WaitWindow, when it returns, will return either the object being waited for or an empty "stub" object with the Exists property = false.  so... something else is going on.  The key is in utilizing the proper wait method.

         

        You have this in your original post:

        var dlg = Aliases.update_complete_window_object_name;

         

        I assume that meant that the Aliases object did have an Alias by the indicated name (update_complete_window_object_name).  

         

        I think what we need to proceed is two things:

         

        1) a screenshot showing your Aliases object and the mapped object that corresponds to the window you are looking for

        2) a screenshot of the object browser showing your application and the dialog window you're looking for.

         

        Those two things will help us figure out the best way to get you what you need.