Forum Discussion

gid_216's avatar
gid_216
Frequent Contributor
13 years ago

Object Not Exist Error

Hi,



While checking whether an object exists or not to proceed further, if the object doesn't exist, then TC automatically insert an error to log making the overall test fail even the test passed. For E.g.

If Not <ObjectToFind>.Exists Then

Log.Message "Passed"

Else

Log.Error "Failed"



here if the object doesn't exist, then script should pass as "Not <ObjectToFind>.Exists" will be True.



But here, the log coming is



Error: The object does not exist. See Additional Information for details.

Message: Passed

and makes the overall script fail. Please give me some solution to overcome such issue.

2 Replies

  • Hi Deepak,



    I use the following syntax (with brackets), which works for me.



    If Not (ObjectToFind.Exists) Then



  • Hi Deepak,

    be aware that Exists is the property of an "existing" object.

    According to how you get your ObjectToFind, it could be a stub object with an Exist property that is false, or it could be null.

    Window(aName) will return null if the window doesn't exist (and add a log ), where waitWindow will return an object with Exist = false and will not add log.

    I guess you've used the first method and the Log entry come from this instruction.



    See http://support.smartbear.com/viewarticle/30939/

    (the behavior is the same with other objects)



    Christophe