Forum Discussion

blearyeye4's avatar
blearyeye4
Occasional Contributor
13 years ago

Object does not exist

I have the following in a JScript:



       var chkUvbSecondary =Aliases....chkUvbSecondary;



where Aliases....chkUvbSecondary forms a path to the object. When I put a breakpoint after this statement and inspect the variable, it shows that it does not exist. However, I know that it in fact exists at the point. I can use Object Spy, for instance, look at it and see its properties. What would be causing this to happen?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Best guess is that something in the Aliasing tree is mapping using a set of properties that is not finding one of the objects.  I would check the tree to see if all the objects can be found (in NameMapping/Aliases, right click on the object and select "View in object browser".
  • blearyeye4's avatar
    blearyeye4
    Occasional Contributor
    I located the object in Name Mapping, found it in the Object Browser, and then highlighted on screen. It all worked. So I'm really puzzled ...
  • blearyeye4's avatar
    blearyeye4
    Occasional Contributor
    Update: After I went through that process, I came back to my script, which was sitting at a breakpoint. To my surprise, the object was shown as existing and the properties for the object were now present. I hadn't made any changes (that I know of), but the act of finding the alias and/or highlighting on the screen seemed to change the state.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Might be that the NameMapping information needed refreshed.  Depending upon what you're doing, you may need to call the "RefreshMappingInfo" method on the parent object before trying to access the child object.
  • blearyeye4's avatar
    blearyeye4
    Occasional Contributor
    That did the trick. 



    I don't quite understand why I should need to do this, however. It seems like "var chkUvbSecondary =Aliases....chkUvbSecondary;" ought to get the properties of the object at the moment it's invoked. Why would "Aliases....chkUvbSecondary" become stale? Are the properties bound at some earlier time?



    In the form's OnLoad method, there will be changes to the relevant controls' properties wrt enablement and visibility. So are the properties of "Aliases....chkUvbSecondary" bound when the object first comes into existence and refreshed only if RefreshMappingInfo is invoked?



    If that's so, then I guess objects should be refreshed whenever there's a possibility that the properties will have changed. It would be nice if there were a property such as Stale that would be true iff the properties had changed. Even better would be an option to refresh objects automatically as necessary when they're used.
  • Hi,



    The Name Mapping information as well as the object tree is cached, and it may be outdated if something changes in your application during the test. Refresh and RefreshMappingInfo methods force TC to reread information on available objects. In most cases, this is not needed, but it can be needed sometimes. This is described in the RefreshMappingInfo Method help topic.



    Instead of RefreshMappingInfo, you can also obtain the target object with the WaitAliasChild method which also refreshes the object tree.