Forum Discussion

Emerson's avatar
Emerson
Occasional Contributor
5 years ago
Solved

Name Mapping: Map two of the same objects to name mapping

Hi,

 

Our software has a dynamic menu. This menu wil l have different tools on it depending on wether the user is on "Standard Tools" or "Maths Tools" for example.

This means that in the object browser if I'm currently on standard tools then the button "BorderContainer("imgBg")" referes to tool x but when I am on maths tools the same name refers to tool y. This means that I can't map both tools in name mapping.

 

Is there a way around this? Or a way in which TestComplete can auto click these buttons on start up and map these objects with different names? 

 

My hope was to create a script similar to this:

if (BorderContainer("imgBg").Exists) {
   BorderContainer("imgBg").Click();
}
else {
    BorderContainer("imgBg", 1).Click();
    BorderContainer("imgBg", 2).Click();
    BorderContainer("imgBg").Click();
}

This would click tool x if it exists or on screen maybe? And if not then it would navigate to the correct tool menu and click tool x. But right now tool x has the same name mapping as tool y so it will always "Exist" or be "OnScreen".

  • Take a look at the "Conditional mode" button at the bottom of the name mapping dialog where you can "AND" or "OR" object conditions to pass the logic.

     

    Cheers

    Lino

3 Replies

  • Wamboo's avatar
    Wamboo
    Community Hero

    Hey,

    In my opinion, it is better for you to map the main form on which the object you are interested in is located, and then use one of the variants of the .findxxx() function on this mapped element.

     

    which is:

    //YourObject -> this is the mapped main form

     

    Aliases.YourApp.YourObject.find("param1", "param1", "depth);

     

    Find the second time this object dynamically after changing into another mode, save it to a variable and you are ready to act.

     

    Let me know if you need any help.

    • LinoTadros's avatar
      LinoTadros
      Community Hero

      Take a look at the "Conditional mode" button at the bottom of the name mapping dialog where you can "AND" or "OR" object conditions to pass the logic.

       

      Cheers

      Lino

      • GAutomation's avatar
        GAutomation
        Frequent Contributor

        Will this work in the below scenario to.

         

        in our name mapping i have moved all the objects to the parent objects  in aliases,so it takes less time for execution. but they are few objects like example print exist in different places and with differnt child objects

        namemapping.Sys.Y.page32270.sub.sub1.print

        namemapping.Sys.Y.page32270.sub.sub12print

         

        can this be used in the  conditional mode too. i tried it is highlighting only onw and not the other. iam i missing something here?