Forum Discussion

savitriv_gadagi's avatar
savitriv_gadagi
New Contributor
13 years ago

Namemapping

Hi,



Is the object recognition in testcomplete based on aliases created or Mapped Objects?

That Means , Say for

 “WPFObject("DragAndDropPanel").WPFObject("Grid", "", 1).WPFObject("ScrollViewer").WPFObject("Grid", "", 1).WPFObject("Panel").WPFObject("LMSListBoxItem", "",



Aliases after name mapping If 2 grids are skipped :

(Aliases.DragAndDrop.ScrolViewr.Panel. LMSListBoxItem)



And Mapped object would be :

(Sys.Namemapping.DragAndDrop.Grid .ScrolViewr.Grid.Panel. LMSListBoxItem)



So after all this, Object recognition is done using Aliases alone? Or using mapped onjects?

Say in next version of softaware under test if property of grid (which is skipped from name mapping)changes , Will the code still works using only the aliases?

1 Reply

  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 2 rankChampion Level 2
    Hi Savitri,



    As its name implies:), Aliases are based on Namemapping.

    Aliases are used to:

    a) Shorten your test code and make it more (visually) understandable; and

    b) Eliminate the necessity to change the test code if namemapping changes.



    Using your sample as an example:

    When you use

    Aliases.DragAndDrop.ScrolViewr.Panel.LMSListBoxItem

    clause in the code, TestComplete internally translates it to

    Sys.Namemapping.DragAndDrop.Grid.ScrolViewr.Grid.Panel.LMSListBoxItem

    and use the latter objects hierarchy to find the target object.

    The test will report an error if some object along the Namemapping path does not exist (for example, if DragAndDrop object is missed or some other object is added between DragAndDrop and Grid).



    But if the objects hierarchy in your application is changed in the next version and you are using Aliases in the test code, the only thing that you will have to do is to adjust Namemapping. Your code will not require changes as long as the Aliases tree remains unchanged.



    Also note, that you may use Extended Find functionality of Namemapping (see help for more details and implementation instructions). With the Extended Find, it is possible to shorten the Namemapping tree to, fo example,

    Sys.Namemapping.DragAndDrop.LMSListBoxItem

    and instruct TestComplete that it must search for LMSListBoxItem element at any level below the DragAndDrop parent. (Alias in this case may be equal to the same value: Aliases.DragAndDrop.LMSListBoxItem.)

    With the Extended Find, neither your code nor Namemapping will require corrections as long as the LMSListBoxItem element is a child of the DragAndDrop one. But obviously, this works slower in applications with a complex UI structure.