Forum Discussion

alex4286's avatar
alex4286
Occasional Contributor
2 months ago
Solved

updating already mapped items to new objects

Dear Support Team,

I’m currently working on a test project where the system under test has changed, and as a result, several previously mapped UI objects are no longer available (they are missing or have new identifiers). I would like to replace an already mapped object in the NameMapping with a newly identified object, but I cannot find a way to do this directly.

Currently, the only way I see is to:

Delete the old mapping,

Create a new mapping,

And then manually update all test steps that reference the old mapped object to point to the new one.

This is highly inefficient for larger projects and prone to human error.

My question is:
Is there a supported way in TestComplete to reassign or relink a mapped object to a different actual object in the repository, without deleting it and updating all affected test steps manually?

  • I re-suggest having a good read of https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/index.html to have deep understanding on how it works to be able to manipulate.

    The links to navigate: Mapped Object > Mapped Alias > Script reference
    In your script you can right click on an action to select speed menu to take you the the Mapped Alias, similarly from the Mapped Alias you can right click on the node to select speed menu to find the Mapped Object.

    1. In the following I intentionally made the path different from Object and Alias to reflect how it actually operates. When you rename Mapped Object Sys.a.b.c.d.e.Button to ButtonOld it will automatically prompt you to rename the Mapped Alias Aliases.a.b.Button and all KeywordTest script references.

    2. When your application mapping path change, and since your scripts are referencing the Alias you can simply modify the Object by drag and drop Button from "e." to higher parent "d." from Sys.a.b.c.d.e.Button to Sys.a.b.c.d.Button. In other cases you can even move it up to "c." and enable/check the extended find to search for it in all children. NOTE: Object and Alias path should not contradict and usually the Alias path skips many of the Object path nodes.

    3. In Alias path when you move one node to a higher parent it will automatically prompt you to update all KeywordTest script references.

    4. The Object and Alias node identification are one and the same. You can update the node identification (by clicking on the image button refresh) and all script references do not need to be updated but are affected immediately.

    5. You can copy an Object node from one project to another, than drag it and drop it in the Alias, and copy the Alias path to use in your script action.

    I suggest you create a test project to play with as you can easily make an irrecoverable mistake.

    💬 Found the answer helpful? Give it a Kudos by clicking Like!
    ✅ Got your issue resolved? Click Mark as Solution so others can find it quickly.

11 Replies

  • alex4286's avatar
    alex4286
    Occasional Contributor

    example I have mapped Object A. It is used in 10 Tests. It was unhapilly recognized as Fullpath, no ID available, so structure changed and it can not be find anymore. I wanted to edit mapped object A in name mapping , so it gets new Object. But Object path there is hardcoded , i can change only attributes of old object. 

  • alex4286's avatar
    alex4286
    Occasional Contributor

    So i mapped new object again and deleted absolete mapping. but now I have to update all steps where old object was used in all 10 Tests. That is somehow not convenient.

  • alex4286's avatar
    alex4286
    Occasional Contributor

    even AutomationID does not help.

     

    there is a ButtonDeleteImage:

    WPFControlAutomationID : DeleteCurrentImageButton

    NameMapping.Sys.Carestream.HwndSource_this.zthis.MainWindowGrid.Grid.Grid.Grid.Grid.Grid.Grid.Grid.this_.ButtonDeleteImage

    Aliases.Carestream.HwndSource_this.zthis.this.ButtonDeleteImage

     

    after Refactoring it is not recognized using DeleteCurrentImageButton AutomationID:

    new object is :

    Aliases.Carestream.HwndSource_this.zthis.this_ref.WPFObject("Grid", "", 1).WPFObject("MenuBottomLine", "", 1).WPFObject("Grid", "", 1).WPFObject("Grid", "", 1).WPFObject("Button", "", 2)

     

    and it still has same WPFControlAutomationID : DeleteCurrentImageButton

     

    • rraghvani's avatar
      rraghvani
      Icon for Champion Level 3 rankChampion Level 3

      As an example, Object Browser shows the following details for the button

      Sys.Browser("chrome").Page("https://www.w3schools.com/css/css3_buttons.asp").Panel(2).Panel(0).Panel("belowtopnav").Panel(0).Panel("main").Button(1)

      The button has the following name mapping

      Sys.browser.pageCssButtons.panelCss.panelCss.panelBelowtopnav.panelCss.panelMain.Button(1)

      If the properties used to identify the button has changed, this can be verified and updated via "Check for Name Mapping updates" button

      The Alias name mapping still remains the same

      However, if the hierarchical structure changes i.e. where Button(1) no longer belongs to Panel("main"), then you will have to perform name remapping. But you can still keep the alias name of Aliases.browser.pageCssButtons.buttonCssButton. 

      • alex4286's avatar
        alex4286
        Occasional Contributor

        Thank you. for me is Huerarchical change very interesting.

        Can you explain more how to proceed? Please

        I try this but seems not always to help.

        1 OLD hierhic. object is mapped with alias "Aliases.xxxxx.HwndSource_this.zthis.a.b.c.Button"

        2 i map NEW hierar. object to Aliases.xxxxx.HwndSource_this.zthis.ButtonNEW

        3 i  delete "Aliases.xxxxx.HwndSource_this.zthis.a.b.c.Button" in NameMapping list

        4 rename ButtonNEW to Button in NameMapping list

        but some how it is not always working :(  it still shows that object not found

        5 looking in test steps where button used it shows "Aliases.xxxxx.HwndSource_this.zthis.a.b.c.Button" so its not updated

         

        I think promlem is that I only change last label  -  Aliases.xxxxx.HwndSource_this.zthis.Button

         

        this part "Aliases.xxxxx.HwndSource_this.zthis." remains unchanged and makes Problem? 

         

        I hope you understand my problem :) 

        _____ _____

        other may be more simple case

        in tests I always click on Ok Button

        but I want now always to clik on Cancel button.

        can I simple change mapping from ok to cancel in name,mapping list?  so i do not need to update all places in tests where Ok was used.

         

  • alex4286's avatar
    alex4286
    Occasional Contributor

    object 1 is used in manu tests and needs to be replaced

    replace with object 2 

     

    How can I replace Object1 with Object2 ? so that Alias remains from Obj1 but has Properties of Obj2, 

    Test steps expects this : 

     

    • Hassan_Ballan's avatar
      Hassan_Ballan
      Icon for Champion Level 3 rankChampion Level 3

      I re-suggest having a good read of https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/index.html to have deep understanding on how it works to be able to manipulate.

      The links to navigate: Mapped Object > Mapped Alias > Script reference
      In your script you can right click on an action to select speed menu to take you the the Mapped Alias, similarly from the Mapped Alias you can right click on the node to select speed menu to find the Mapped Object.

      1. In the following I intentionally made the path different from Object and Alias to reflect how it actually operates. When you rename Mapped Object Sys.a.b.c.d.e.Button to ButtonOld it will automatically prompt you to rename the Mapped Alias Aliases.a.b.Button and all KeywordTest script references.

      2. When your application mapping path change, and since your scripts are referencing the Alias you can simply modify the Object by drag and drop Button from "e." to higher parent "d." from Sys.a.b.c.d.e.Button to Sys.a.b.c.d.Button. In other cases you can even move it up to "c." and enable/check the extended find to search for it in all children. NOTE: Object and Alias path should not contradict and usually the Alias path skips many of the Object path nodes.

      3. In Alias path when you move one node to a higher parent it will automatically prompt you to update all KeywordTest script references.

      4. The Object and Alias node identification are one and the same. You can update the node identification (by clicking on the image button refresh) and all script references do not need to be updated but are affected immediately.

      5. You can copy an Object node from one project to another, than drag it and drop it in the Alias, and copy the Alias path to use in your script action.

      I suggest you create a test project to play with as you can easily make an irrecoverable mistake.

      💬 Found the answer helpful? Give it a Kudos by clicking Like!
      ✅ Got your issue resolved? Click Mark as Solution so others can find it quickly.

      • alex4286's avatar
        alex4286
        Occasional Contributor

        Thank you. I read it, may be I still do not get all but it works step by step

        this helps:)

        2. When your application mapping path change, and since your scripts are referencing the Alias you can simply modify the Object by drag and drop Button from "e." to higher parent "d." from Sys.a.b.c.d.e.Button to Sys.a.b.c.d.Button. In other cases you can even move it up to "c." and enable/check the extended find to search for it in all children. NOTE: Object and Alias path should not contradict and usually the Alias path skips many of the Object path nodes.

         

        I mapped new object to get correct hierarc. Then moved old and already used button to new place where new object was. 

  • alex4286's avatar
    alex4286
    Occasional Contributor

    resolved. thanx

     

    may be it will be cool if test complete would have an easy  button just to assign new object to mapped alias . like using in object spy