Forum Discussion

Gordian's avatar
Gordian
Occasional Contributor
10 years ago

How to tell if a project has a name map programmatically

TestComplete 10.6, JScript, Java app in a browser

 

 

I have a script extension for some general purpose operations (JScript).  In this code I want to programmatically determine if the current Project in the Project Suite has a Name map included.  If it does, then the script extension will call RefreshMappingInfo() which only works if the project has a name map included.

 

How do I determine dynamically if the project has a name map?

 

  • In script extensions, you can check the presence of NameMapping like this:

     

    var nmExists = false;
    try {
      nmExists = NameMapping.ConfigurationCount > 0;
    }
    catch (e) {}
    
    if (nmExists)
    {
      // The current project has a name map
    }

     

    In regular test scripts, you can use this:

     

    if (typeof NameMapping !=== "undefined")
    {
      // The current project has a name map
    }
    else
    {
      // The project doesn't have a name map
    }

     

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    In script extensions, you can check the presence of NameMapping like this:

     

    var nmExists = false;
    try {
      nmExists = NameMapping.ConfigurationCount > 0;
    }
    catch (e) {}
    
    if (nmExists)
    {
      // The current project has a name map
    }

     

    In regular test scripts, you can use this:

     

    if (typeof NameMapping !=== "undefined")
    {
      // The current project has a name map
    }
    else
    {
      // The project doesn't have a name map
    }