Name Mapping is the most important and exciting feature of test complete, Using this feature you can create a mapped name using the properties of the object in our application, which can then used to refer the object in the scripts. You must be wondering like, why we need this name mapping when TestComplete already lets us identify an object uniquely by object name format. Well… the problem is, object name depends on the object properties which is not consistent and can change from one application to another. Another problem is, the object names are quite long and not easily readable. At the same time it is very confusing to get the context of a particular statement.
Applications in the Windows system, subordinate to the application form, form controls are objects, each object has a unique identifier , they work together to build a huge object tree, the root node is Sys, can imagine a decked out hexadecimal number of the leaves of the tree, every leaf Properties Methods Events decorate it, if the recorded code hexadecimal numbers do object name all will collapse, so we must first of these objects a name, the most simple ideas is to use this object similar to the caption, index and classname attributes to a name, so TestComplete memory each object from the name, in order to clearly show the hierarchical relationship of the individual objects, use the fullname to identify. The Full Name looks probably like this:
Sys.Process ("IEXPLORE"). Page ("http://xxx:nn/xxx.html"). Panel ("ext_comp_1017"). Panel ("ext_gen15"). Panel ("ext_gen16"). Panel (" ext_comp_1009 "). Panel (" ext_gen26 "). Panel (" ext_gen28 "). Panel (" ext_comp_1008 "). Panel (" ext_gen75 "). Panel (" ext_gen76 "). Panel (" ext_comp_1073 "). Panel (" ext_gen161 "). Panel (0). Panel (0). Panel (0). Panel (" ext_gen162 "). Panel (" ext_comp_1075 "). Table (0). Cell (0,7). Table (" ext_comp_1048 ") . Cell (0,1). Button ("ext_gen195")
Referring objects here is little dizzy, isn’t it …? , its very long and is not easy to write and read. To Solve this issue, TestComplete provides Name Mapping using which we can refer objects and unique names. The statement will become readable.
Using the selected properties, Test Complete identifies the object using the properties and assigns a Mapped name to that object.
While creating a mapped name you need to provide a reasonable name for mapped name and select few unique identifiers for the object.
After creating Name Mapping for every object, we can refer to the object as follows.
It’s clear that this is easier to read. Even though it is easy to read, still the name is too long. It will be difficult to remember all the Mapped names and their hierarchy. So you end up getting the full mapped name of the object by using the object spy. As a result productivity goes down because you have to go through several steps to pick out the name.
To resolve this problem, we can use Alias names. From the above mentioned mapped name, we can remove a few objects and create a short name. For example the Aliases name of the above object can be given as follows.
This becomes very easy to read and write. Also we can easily memorize the names of required objects alone and type them in our scripts (without the help of the object spy).
To Map an object
Click on ‘Map Object From Screen’ button in TestComplete toolbar. alternatively you can select map object from Object browser right click menu.
This opens Map Object window. Drag the Finder tool to the Object you want to add and release the mouse button. Click OK Once done.
In the next screen it asks to map all the parent objects. Click Yes.
Map all the required objects with a readable and clear name until you get your object.
When all the object is mapped open Name Mapping Item. this reveals the name mapping which you just created. You can see the Mapped Objects in a tree format. You will also see the Alias names which are created by default (in the same hierarchy as the Name Mapping).
If you use this default Aliases name, it will come to the same length as Full Mapped name. Remove the names of some unwanted higher level objects by dragging the objects into aliases under the required object hierarchy.