Forum Discussion

MaksZin's avatar
Occasional Contributor
2 years ago

How to avoid changing URL in name mapping manually for each object?

We created some tests in out TC project. We want to be able to run them in multiple environments (each environment has base URL and some test data) so we created project variables like baseURL. We use a script running before tests to load base URL from configuration file, so we do not need to update variable manually in each test when we want to run tests in specific environment. The problem is that in Name Mapping objects still have hardcoded values like "ObjectType: URL, Page:". Now when we run tests in UAT env, test step opens page correctly in UAT env, but fails because object in Name Mapping is pointing to 


This can be solved by using wildcards Using Wildcards | TestComplete Documentation ( However, we have dozens of objects in Name Mapping under browser object pointing to some URL. Updating them manually will be very time consuming and every time we create new test by recording script, new objects with URLs are added to Name Mapping. 

Is there a way to make our tests work in multiple environments without updating URL for each object in Name Mapping manually?


Thank you,





3 Replies

  • rraghvani's avatar
    Champion Level 3

    From the looks of it, your structure doesn't look correct. What's the difference between these,




    If you're testing one website, then the top most node should have a reference to the URL

    All objects beneath that i.e. linkHtmlIntroduction, linkHtmlEditors, linkHtmlElements etc do not have references to URL.

    If the DOM remains the same, but only the URL changes, then I can change the main URL.


    See Name Mapping, it's vital to get object identification correct, to instruct TestComplete on how to locate the object in your tested application.

  • Kitt's avatar
    Regular Contributor

    More specifically you want to use "conditional" mapping for you base page objects and use a Project.Variable.baseURL (or whatever you call your variable) as a condition - then use the hard coded base urls as a fallback/failsafe:

    [TestComplete reference]

    *** be sure you are setting your NameMapping Project.Variables before the test starts or before you look for the object - so use the OnStartTest event or your own script to handle accordingly. 

  • tvklovesu's avatar
    Frequent Contributor

    Also you can use Wildcard with in the URL instead of passing the variable like

    instead of*




    This will work no matter which environment you are running the test in

    in the image below you can see that the hierarchy of all the elements. The browser should be below sys and the page should be below browser and finally all the objects should be below page. While recording the script the TC will automatically arrange them. Not sure why your name Mapping objects are arranged like that.