Forum Discussion

Kenny_Mooney's avatar
Kenny_Mooney
Occasional Contributor
10 years ago

TestComplete "Losing" Methods from NameMapping

Hi 

 

I am currently getting "Unable to find the object" errors when running a script that calls a method on a Delphi grid component. Everything is correctly NameMapped and given Aliases, and on just opening TestComplete for the first time and inspecting the grid component in the application, I see the method there in the Object Browser. But when the script is run I get the error and if I then check the object again, the method has gone.

 

Rather baffled, and I'm a new user to TestComplete. Any ideas greatly appreciated.

  • Kenny_Mooney's avatar
    Kenny_Mooney
    10 years ago

    Many thanks for the help. I have now solved the problem I was having by going through the script manually, and I managed to find a line of code that appears to have caused this, although I don't fully understand why.

     

    The script just has two routines, and in the first there was a line of code that executed a method of a completely different grid instance (same type of component, but used in a totally different part of the application). When I altered this so that it no longer called that method, my original problem was fixed. Something like this:

     

    Sub Routine1

      Call MyGrid.Method1() //Calling this appears to have altered all the grids of this type in the namemapping

    End Sub

     

    Sub Routine2

      Call DifferentGrid.Method2() //This is the method that failed

    End Sub

     

    The solution I have works, but not understanding the cause is a bit frustrating, because I don't know if I'll encounter a similar issue again.

     

    Thanks for the help, it did help me narrow this down.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    If it wasn't for the fact that you are manually checking the object out side of and separate from a script run, I'd call this a classic "timing" problem solvable by using a WaitNNN method on your parent object (WaitAliasChild, etc). As it is, check out the help topics on these methods to see if you can implement them. I'd say that any script project that has occasional errors of "Unable to find object" or "Object does not exist" can benefit from these.

    As for your specific problem, have you tried manually executing the tests of the test script leading up to the "missing" method? Is it possible that something you're doing in your application under test during the course of the test is altering the grid?

    Additionally, is it possible that, while the script is recognizing the grid as your namemapped object, that it might actually be a DIFFERENT object that looks the same and has some similar properties? You might want do do a comparison of the full set of properties of the object when you first start TestComplete to the properties of the object after the scripts to see if there are significant differences.

    I'm interested in your findings... please report back with screenshots and logs and we'll see if we can help out.
    • Kenny_Mooney's avatar
      Kenny_Mooney
      Occasional Contributor

      Many thanks for the help. I have now solved the problem I was having by going through the script manually, and I managed to find a line of code that appears to have caused this, although I don't fully understand why.

       

      The script just has two routines, and in the first there was a line of code that executed a method of a completely different grid instance (same type of component, but used in a totally different part of the application). When I altered this so that it no longer called that method, my original problem was fixed. Something like this:

       

      Sub Routine1

        Call MyGrid.Method1() //Calling this appears to have altered all the grids of this type in the namemapping

      End Sub

       

      Sub Routine2

        Call DifferentGrid.Method2() //This is the method that failed

      End Sub

       

      The solution I have works, but not understanding the cause is a bit frustrating, because I don't know if I'll encounter a similar issue again.

       

      Thanks for the help, it did help me narrow this down.