Forum Discussion

ecertain's avatar
ecertain
New Contributor
7 years ago

Identical Instances of an Object in same window - Same Mapped Name.

I need to be able to use buttons or icons that have identical properties, except for dynamic properties such as Id or position related items.  Below shows two sets of identical buttons/icons that are reused on a single window.  I'd like to be able to use a 'Next()' feature or some way to use an enumeration or array of them and choose the one I want, being I am unsure how i'd get a different map out of these.  I've included some snapshots of the properties below as well, using the Object Spy.

 

 

  • What I would do is delete them both from the mapping and remap them.  Accept the default mapping from TestComplete so it takes the whole path.  That will get you the different ancestries and keep them separate.  Then you can change their Aliases if you want but keep them separate too.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    They aren't the same object... they have different parent objects.  

     

    Let's start with the "inquire" buttons...  please show me the NameMapping screen in TestComplete where those buttons are identified, displaying the hierachal tree to the objects including the "Extended Find" checkbox column.  My guess is that somewhere in the ancestral hierachy of those objects there is a common parent and then the child objects off of it have the "extended find" flag checked... TestComplete uses hierarchy AND properties to identify an object... so, if the hierarchy is improperly "compressed" with the extended find, you'll get the behavior you're seeing.

    • ecertain's avatar
      ecertain
      New Contributor

      Both of you see something in the hierarchy that shows you that the objects have a different ancestry--is this what your seeing :  

      Sys.Process("advantage-ui").WPFObject("HwndSource: mainWindow").WPFObject("mainWindow").WPFObject("layoutRoot").WPFObject("mainDataViewPort").WPFObject("Grid", "", 1).WPFObject("Grid", "", 1).WPFObject("TabControl", "", 1).WPFObject("ContentPresenter", "", 1).WPFObject("AdvView", "", 1).WPFObject("ExtendedScrollViewer", "", 1).WPFObject("AdornerDecorator", "", 1).WPFObject("Grid", "", 1).WPFObject("cENTRY_FRAME").WPFObject("Grid", "", 1).WPFObject("c31_SEARCH_LIST_FRAME").WPFObject("Grid", "", 1).WPFObject("AdvFrame", "", 1).WPFObject("Grid", "", 1).WPFObject("c33_SEARCH_RESULTS_FRAME").WPFObject("Grid", "", 1).WPFObject("AdvFrame", "", 2).WPFObject("Grid", "", 1).WPFObject("AdvFrame", "", 1).WPFObject("Grid", "", 1).WPFObject("c66_BTN_I").WPFObject("StackPanel", "", 1).WPFObject("Label", "_Inquire", 1).WPFObject("AccessText", "_Inquire", 1)

       

      Sys.Process("advantage-ui").WPFObject("HwndSource: mainWindow").WPFObject("mainWindow").WPFObject("layoutRoot").WPFObject("mainDataViewPort").WPFObject("Grid", "", 1).WPFObject("Grid", "", 1).WPFObject("TabControl", "", 1).WPFObject("ContentPresenter", "", 1).WPFObject("AdvView", "", 1).WPFObject("ExtendedScrollViewer", "", 1).WPFObject("AdornerDecorator", "", 1).WPFObject("Grid", "", 1).WPFObject("cENTRY_FRAME").WPFObject("Grid", "", 1).WPFObject("AdvFrame", "", 2).WPFObject("Grid", "", 1).WPFObject("c73_SEARCH_RESULTS_FRAME").WPFObject("Grid", "", 1).WPFObject("AdvFrame", "", 2).WPFObject("Grid", "", 1).WPFObject("AdvFrame", "", 1).WPFObject("Grid", "", 1).WPFObject("c87_BTN_I").WPFObject("StackPanel", "", 1).WPFObject("Label", "_Inquire", 1).WPFObject("AccessText", "_Inquire", 1)

       

      I clearly see that your correct, it is a different path when reviewing the path above--I see both items in the object browser as a different object.  However, both are mapped (alias) to the same object (MappedName), maybe its my template i'm using or something else.  I attached an image of the different object mappings.

       

      When I double click on the item to get the properties, here are the alias's:

      #1 InquireLabel
      Aliases.advantage_ui.HwndSource_mainWindow.mainWindow.mainDataViewPort.Grid.Grid.TabControl.ExtendedScrollViewer.LabelInquire
      #2 InquireLabel
      Aliases.advantage_ui.HwndSource_mainWindow.mainWindow.mainDataViewPort.Grid.Grid.TabControl.ExtendedScrollViewer.LabelInquire

       

      I attached an image of the above mapping: mappedObjectIdenticalObjects.png

       

      When I uncheck the extended find (it was checked), i Testcomplete cannot find it, it comes back as "Ambiguous recognition of the tested object....The "LabelInquire" does not exist"-which tells me there are more than one of the same item and doesn't know which to select.

       

      I am using a template in order to map the objects as well for this desktop/wpf application using customer controls. 

       

      I appreciate both responses, and my response can be safely ignored if i'm not understanding.    I am not sure how i'd change or update the mappings in the ancestry of the objects to have a different parent?  Would adding the property of "FullName" to the template do this, or would changing the alias name of the  'MappedName' in the object browser do that, or something else?  

      This has been a good learning experience--and thanks ahead of time!

      Erik 

      • Marsha_R's avatar
        Marsha_R
        Moderator

        What I would do is delete them both from the mapping and remap them.  Accept the default mapping from TestComplete so it takes the whole path.  That will get you the different ancestries and keep them separate.  Then you can change their Aliases if you want but keep them separate too.

  • The two controls are having different object hierarchy. We can see this clearly in the Object Browser. If we map both the controls starting from their highest level parent control we can see that at some level both the controls will have  a different parent and hence we will be able to identify the controls uniquely if we can find properties combination that can identify this parent control uniquely

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor
      Exactly. Make those mappings in the ancestry of the objects and you'll have two unique objects. Let us know how it works out.