Forum Discussion

Riquochet's avatar
Riquochet
New Contributor
14 years ago

Name Mappings Lost after Several Test Runs

If we run the same test over and over (about 15 times,) TestComplete seems to "forget" the name mappings for some of our Java controls. If we run any other test, those controls' name mapping are still not found. The only way to resolve the problem is to shut down our application. After the application restart, the name mappings work just fine.



We have the same problem when we running our whole test suite. At seemingly random time, the name mappings seem to be lost. The only way to resolve this is to do the same thing above. 


3 Replies

  • Hi,


    When you obtain a mapping item or alias for the first time, TestComplete searches for the object in the object tree and stores a reference to this object. Then, when you use the mapping item or alias in tests, TestComplete uses the stored reference to forward the method calls to the mapped object. If the object is recreated, the reference becomes invalid. In such cases, you can update the reference to the underlying object by calling the NameMappingItemObj.RefreshMappingInfo or AliasObj.RefreshMappingInfo method.

  • Riquochet's avatar
    Riquochet
    New Contributor

    We do call that method every time we open the dialog (on the dialog object) with the control that is "forgotten."



    Do I need to call it on that specific control? Will I have to do it for every control in that dialog? That seems a bit extreme. 
  • Hi,




    Do I need to call it on that specific control?


    Yes, you need to call the RefreshMappingInfo method for the control that is "forgotten".




    Will I have to do it for every control in that dialog?


    If the references to other controls become invalid during the test run, you need to use this method for these controls as well. To avoid extra calls to the RefreshMappingInfo method, you can use the following Exists function to check if the mapped object exists. It will update the mapping information only if the mapping item has a reference to a non-existing object.




    function Exists (NameMappingItem)

    {

      // Check if the name mapping item refers to an existing object

      if (NameMappingItem.Exists)

        return true

      else

        // Refresh the mapping information to see if the object has been recreated

        NameMappingItem.RefreshMappingInfo();

        return NameMappingItem.Exists;

    }