Forum Discussion

guillaume's avatar
guillaume
Contributor
13 years ago

Object.VisibleOnScreen and The object does not exist

Hello.



I am using TC8 to do some webtesting. I extended the WaitPage method from browser with some additionnal requirement in order to be sure that the webpage has been completely loaded.



The method is looking for the jqueryLoader element in the webpage. If the object is found, it waits for the property VisibleOnScreen to be false. Here is a piece of the code used :



var objPage = Aliases.theBrowser.page;

[...]

var objLoader = objPage.WaitAliasChild("jqueryLoader", 500);

while(objLoader.Exists && objLoader.VisibleOnScreen){

   Delay(500);

   objLoader = objPage.WaitAliasChild("jqueryLoader", 0);

}



Unfortunately, at run time I sometime get the The object does not exist (An error occurred while calling the VisibleOnScreen method or property. The object or one of its parent objects does not exist).



I expected the objLoader.VisibleOnScreen to be called only when objLoader exists.



Did I misunderstood something ?

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    When using WaitAliasChild and the object returns as Exists = False, the object is actually an empty stub with minimal properties.  VisibleOnScreen is one of the properties that does not return and so you'll get the error you've reported.



    You should test for Exists independent of VisibleOnScreen.  Only if Exists returns true can you verify VisibleOnScreen.
  • Hi Robert.



    I actually got the stub in mind while doing this routine.

    The thing is, I am actually surprised that since the Exists property is false, the while routine keeps looking for VisibleOnScreen.



    I would expect the jScript engine to be able to exit the while loop as soon as one of the property is false, but maybe I am wrong.



    Thanks for the tips.



    Guillaume.