Forum Discussion

efuller's avatar
efuller
Occasional Contributor
8 years ago

Close specific browser script error

Hello Everyone, I created a script to check for specific web browsers exist, and if so to close them. Otherwise, just add a log message to say the browser wasn't open. Unfortunately I'm getting odd ...
  • AlexKaras's avatar
    8 years ago

    Hi,

     

    A little bit to add to what was said by baxatob to ease your confusion :) :

    TestComplete can get a reference to any tested object using either 'direct' syntax (like Sys.Browser()) or 'indirect' one (like Sys.WaitBrowser()). Basically, any get/search function has its WaitXXX complimentary one.

    The difference is that when 'direct' object addressing is used, this tells TestComplete that you are sure that the addressed object must exist. This is the reason for TestComplete to report a problem if directly referenced object cannot be found.

    In case of 'indirect' addressing via the WaitXXX(), this means that the sought for object may not exist and the error is not reported if the object is not found.

    As for .Exists property: if the object was found when been 'directly' referenced, .Exists obviously equals to True.

    But if you got a reference to, say, var b = Sys.Browser("chrome") when it was running and than closed it, then b.Exists will evaluate to False.

     

    That is why if you are not certain whether or not some object exists at the given moment, you should try to get a reference to it using corresponding WaitXXX() function, check the value of .Exists and proceed appropriately.