The Name Mapping repository stores all your tested objects with their custom name and with their identification criteria. TestComplete uses the criteria to locate the objects in your tested application before simulating user actions over the objects. TestComplete stores the criteria in the Name Mapping repository automatically when you record tests or when you add objects to the repository manually.
About selectors
To locate elements in web applications and objects in mobile applications running in device clouds, TestComplete uses search expressions called selectors.
For web applications, a selector can be an XPath expression or a CSS selector. For mobile applications, it can be an object identifier, a class name, or an XPath expression.
When locating the object, TestComplete will go through the specified selectors one after another in the order the Name Mapping editor lists them until it finds an object that matches the selector or until there are no more selectors left.
Requirements
For web applications
Starting from version 14.50, TestComplete locates web elements by selectors in all new projects by default.
You can control this:
-
When you create a new project via the File > New > New Project wizard.
-
When you record a new test via the Start Page > Record Test wizard.
-
On the Open Applications > Web Testing > General page of the existing project’s Properties page.
For mobile applications
In mobile applications running in device clouds, TestComplete always locates objects by using selectors.
Edit mapping criteria
To add a new selector
By default, when an object is mapped, TestComplete adds all possible selectors that can be used to locate the object to the repository automatically. To add a selector manually:
-
Select a mapped web object whose identification criteria you want to modify (you can select the object in the Mapped Objects tree or in the Aliases tree).
-
To the right of the selector list, click Add.
-
Enter an expression to use to locate the mapped object.
-
If needed, change the selector priority by using the Move Up and Move Down buttons.
To modify a selector
Click the selector in the list of mapping criteria and type the new search expression.
To use variables in selectors
Replace the entire selector expression or a part of it with the name of the project variable that stores the needed value. Use the following syntax:
For variables of a simple type (string, integer, double, boolean)
Enclose the variable name in %. For example, //input[@id='%myvar%']
.
For DB table variables
Enclose the variable name in % and specify the name of the column from which the needed data will be extracted. For example, //input[@id='%myvar(Column1)%']
.
If the test includes a single iteration, the variable will get the data from the first row of the specified column. If the test includes several iterations (a data-driven test), the variable will get the data from the specified column one row after another.
If you specify the variable that does not exist in your project, your test will report an error.
TestComplete caches mapped objects. If the variable value is updated during the test run, TestComplete may not update the mapped object’s criteria, and your test will continue using the cached object. To avoid possible issues, add the RefreshMappingInfo
method to your test to command TestComplete to clear the cache and search for the object with the updated mapping criteria.
To disable a selector
To temporarily exclude a selector from the list of mapping criteria, clear the check box next to the selector.
To change the selector priority
When trying to locate a tested web object, the test engine checks the selectors in the order they are listed by the editor.
Select the selector whose priority you want to change and click Move Up or Move Down respectively.
To delete an expression
Select a selector in the list and click Remove.
Update mapping criteria by pointing out the object on the screen (for web objects only)
If a tested web object in the application has been modified, to keep the identification criteria valid, you can update them to match the actual state of the object:
-
Before you start, make sure that you have one of the supported web browsers running, and a web page that contains the target web object is open in it.
-
In the Name Mapping repository, select a mapped web object whose identification criteria you want to update.
-
Click Update selectors on the repository toolbar.
-
In the resulting Update Selectors from Object dialog, select one of the tools and use them to point to the target object on the screen.
-
Click OK.
TestComplete will replace the existing identification criteria with the new ones to match the object you have pointed to on the screen.
See Also
Name Mapping
Name Mapping - Basic Mapping Criteria
Name Mapping - Conditional Mapping Criteria
About Cross-Platform Web Tests
About Mobile Tests