Forum Discussion

Vaccanoll's avatar
Vaccanoll
New Contributor
7 years ago
Solved

Make Named Mapping not care about the "Path"

My application has unique names for every single UI element.  But the UI does change on occasion as development is on going.

 

When I try to setup my application in Name Mapping, I set the ObjectType (input, select etc) and the ObjectIdentifier (the unique name).

 

This is more than enough to identify any element in my application.  And it all seems to work except that if the developers add a div around my element (or remove one), the name mapping breaks!

 

That is confusing, because I am not mapping on its "path".  When I open the broken mapping/alias, it says:

 

The object must correspond to the 'NameMapping.Sys.browser.myPage.panel.panel.panelColMd9.panelFormGroup.fieldset.MyMappedName'

 

Why does it do that?  I have told it that I only want to use ObjectIdentifier and ObjectType.  Why must it lock it into a path?  This makes all my tests that use the mapping super SUPER brittle.  

 

On top of that, fixing the broken mapping is hard.  Really hard.  It is almost easier to start over each time.

 

I am a bit frustrated as this product seems to be setup for me to fail, and a paid product should not do that!

  • It has to do with hierarchy... NameMapping identifies an object using two sets of criteria

     

    1. What object are they a child of
    2. What properties they have

     

    Basically, NameMapping will look at Sys and see "Do I have a child that matches the properties of 'browser'"? If so, it returns the browser... then it says, "Does browser have a child that matches the properties of 'myPage'?" If so, it returns myPage... and so on.  NameMapping doesn't scan the whole page to find the component, it only searches based upon the hierarchy tree.

     

    So, when the developers added their DIV, they changed that hierarchy.... so, yes, initially it "breaks".  However, TestComplete has a feature that "fixes" this called "Extended Find".  There are two ways of doing this. First, you can have TestComplete automatically apply "Extended Find" everytime you map something.  This is done under Tools -> Options -> Engines -> NameMapping.  There's an option there that says, "Use extended find when possible".  If you check that item and you map a component, instead of 

     

    NameMapping.Sys.browser.myPage.panel.panel.panelColMd9.panelFormGroup.fieldset.MyMappedName

     

    you might see something more like

     

    NameMapping.Sys.browser.myPage.panelFormGroup.fieldset.MyMappedName

     

    as the extended find will "collapse" the extra panels.  This shows up as a checkbox in your namemapping tree on "panelFormgroup" that is checked.  Basically, this tells NameMapping to search all children of MyPage and their children and their children and so on until you find, in the hierarchy starting with MyPage and object that matches the properties.  This way, if the developers add a DIV or remove a DIV between myPage and panelFormGroup, TestComplete will still find the component.

     

    Even if you don't want Testcomplete to do this automatically, that "Extended Find" checkbox is always available.  So, you can go to your namemapping, check that box beside "panelFormGroup" and then drag that component to be a child of myPage and then delete the intervening panels.  That way, no matter how many DIVS the developers add or remove between myPage and panelFormGroup, it will always find the component.

     

    Several resource for you for this. Go to https://support.smartbear.com/testcomplete/videos/?utm_source=TestComplete&utm_medium=StarterPage and there's a video there on "How To Use Extended Find" which is VERY helpful.

     

    The help topic that goes along with this is https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/managing/modifying/extended-search-criteria.html

     

    Just as a side note: I rarely keep the "automatic" mappings that TestComplete makes for me.  I would say about 95% of the time, after TestComplete maps something for me, I go back and make adjustments and edits to the mapping to account for just this kind of deal.

     

     

     

     

     

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    It has to do with hierarchy... NameMapping identifies an object using two sets of criteria

     

    1. What object are they a child of
    2. What properties they have

     

    Basically, NameMapping will look at Sys and see "Do I have a child that matches the properties of 'browser'"? If so, it returns the browser... then it says, "Does browser have a child that matches the properties of 'myPage'?" If so, it returns myPage... and so on.  NameMapping doesn't scan the whole page to find the component, it only searches based upon the hierarchy tree.

     

    So, when the developers added their DIV, they changed that hierarchy.... so, yes, initially it "breaks".  However, TestComplete has a feature that "fixes" this called "Extended Find".  There are two ways of doing this. First, you can have TestComplete automatically apply "Extended Find" everytime you map something.  This is done under Tools -> Options -> Engines -> NameMapping.  There's an option there that says, "Use extended find when possible".  If you check that item and you map a component, instead of 

     

    NameMapping.Sys.browser.myPage.panel.panel.panelColMd9.panelFormGroup.fieldset.MyMappedName

     

    you might see something more like

     

    NameMapping.Sys.browser.myPage.panelFormGroup.fieldset.MyMappedName

     

    as the extended find will "collapse" the extra panels.  This shows up as a checkbox in your namemapping tree on "panelFormgroup" that is checked.  Basically, this tells NameMapping to search all children of MyPage and their children and their children and so on until you find, in the hierarchy starting with MyPage and object that matches the properties.  This way, if the developers add a DIV or remove a DIV between myPage and panelFormGroup, TestComplete will still find the component.

     

    Even if you don't want Testcomplete to do this automatically, that "Extended Find" checkbox is always available.  So, you can go to your namemapping, check that box beside "panelFormGroup" and then drag that component to be a child of myPage and then delete the intervening panels.  That way, no matter how many DIVS the developers add or remove between myPage and panelFormGroup, it will always find the component.

     

    Several resource for you for this. Go to https://support.smartbear.com/testcomplete/videos/?utm_source=TestComplete&utm_medium=StarterPage and there's a video there on "How To Use Extended Find" which is VERY helpful.

     

    The help topic that goes along with this is https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/managing/modifying/extended-search-criteria.html

     

    Just as a side note: I rarely keep the "automatic" mappings that TestComplete makes for me.  I would say about 95% of the time, after TestComplete maps something for me, I go back and make adjustments and edits to the mapping to account for just this kind of deal.

     

     

     

     

     

    • Marsha_R's avatar
      Marsha_R
      Champion Level 3

      I agree with tristaanogre.  If I'm starting on a new mapping, I always edit it to fit our standards.  If I'm using an existing mapping and the parents are already well defined, only then will I accept the automatic mapping from TC.  

       

      The auto features for name mapping and everything else are a great place to start and learn from, but everyone has different software to test and we all have different requirements and we have to fine tune things to work best in our own environments.  Even so, someone on the forums here may have done something similar to what you are doing and be able to help.  

       

      Always post questions here when you get stuck and give lots of details.  Someone can help you figure it out!