Forum Discussion

rajvansh's avatar
rajvansh
New Contributor
10 years ago

Testcomplete:NameMapping: Can we read & write properties for mapped objects in NameMapping by code?

We need to update properties for a large number of mapped ojects in an existing NameMapping. Is there a way to do this via a script?

 

eg. I have an object  

 

NameMapping.Sys.WerFault.dlgMicrosoftWindows.DirectUIHWND.CtrlNotifySink.btnCancel 

 

Properties of btnCancel:

WndClass: Button

Wndcaption: Cancel

 

In want to read Wndcaption 'Cancel' and change it to 'Close'. Is this possible to do this via code. Please note that I need to do this for more than 3000 objects...pls do not suggest storing the object property value as variables....

 

Need this urgently...Please help...

 

3 Replies

    • rajvansh's avatar
      rajvansh
      New Contributor

      Hi Tanya,

       

      Thanks for your response!!!

       

      We checked the 'Update Name Mapping during test run' checkbox. However when we run the scripts on application with modified objects, the script fails to recognize/modify object at runtime.

       

      Also as per the description for this option "If this option is selected, TestComplete prompts you to update invalid mapping criteria found during the test run.". It looks like the user would be prompted to update the namemapping. What we are looking to do is modify the name mapping before automatically.

       

      Please cosider the following scenario...

       

      1. Theere is a button 'Ok' (WndCaption=OK)in our application which is already mapped.

      2. Now name of the button has changed to 'Ok1'(WndCaption=Ok1).

      3. We want the name mapping to either get updated via a setting in TC OR if there is a possibilty changing the properties directly into namemapping by code.

      Current:

      OBJ1.WndCaption=OK

      Expected:

      OBJ1.WndCaption=Ok1

       

      I tried storing the Oject property as a variable and updated it during execution. However this is not efficien for the high no. changes that we need to handle.

       

      Regards,

      Tushar

      • lleppert's avatar
        lleppert
        Contributor

        Hi rajvansh,

         

        The namemapping file can be opened in a text editor and edited that way. Therefore, if you know the old object names and what they are being changed to you can simply perform a find and replace int he text editor. If you have multiple namemapping files, like we do, you can create a script that will do a find and replace on each file.

         

        Hope that helps,

         

        Lauren