Forum Discussion

kingsmartbear's avatar
kingsmartbear
Contributor
15 years ago

How do I know if an object was destroyed for some reason?

Hi  All:



  I got a problem with Object.Find method when I was searching an object within object hierarchy in TC 8.5.



  When I used object browser to inspect  what was problem for this situation I found  the object I was using for find method was destroyed and it still

there with a lot of error messages for most attributes.



  How do I know the object is destroyed before I use it?



  Sample code in below and screenshot in attached file:



   If isobject(object) then

     Set returnObject= Object.find(propertyArray, valueArray, depthvalue)

   Else

     Log.Message "object problem."

   End if



Thanks,



Allan

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Check the "Exists" property of the object.  If Exists is false, the object has been destroyed.
  • karkadil's avatar
    karkadil
    Valued Contributor
    Robert's solution will work, however I think that if an object doesn't exist, then error message will be posted to the log.



    But I haven't checked if it is true, so you need to find this out by yourself :)
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Based upon the screenshot provided, the object is stubbed out in memory with Exists as false.



    However, Gennadiy's comment is a good one.  If you suspect that an object will be destroyed between events in your automation, you might want to make sure you use some sort of WaitNNN method and/or a Find method to check for the existence of the object before proceeding.
  • Hi Robert and Gennadiy:



       Thanks for you solution, I'll give it a try and let you know the result.



    Regards,



    Allan