Using Variables in Tested Application Paths

Applies to TestComplete 15.47, last modified on January 20, 2023

An application can be installed to different folders on different computers. Even the default installation path can differ between Windows versions and different users. For example, an application could be installed to the C:\Program Files folder on a 32-bit Windows version and to the C:\Program Files (x86) folder on a 64-bit Windows version. For another example, if an application could be installed to the user profile folder and so have different paths for different users.

If you run tests on multiple computers, it is essential to specify the tested application path in a computer-independent manner. For this purpose, TestComplete lets you use environment variables, as well as project and project suite variables in the tested application path, working folder and other parameters that include file and folder paths.

Environment variables must be specified in the format %VarName%. Project and project suite variables must be specified in the format $(VarName). For example:

%PROGRAMFILES%\MyApp\MyApp.exe

$(AppPath)\MyApp.exe

In the TestedApps editor, you can click the down arrow button next to any path parameter to see whether some path components can be substituted with the existing environment variables. If replacement is available, you can apply it by selecting the parameterized path from the list.

Substituting path components with environment variables

In a similar way, you can switch back from the parameterized path to the fully-qualified path, if needed.

Notes

  • A newly created environment variable is available only to applications that were launched after the variable was created. Applications launched before the variable was created do not “see” this variable. Make sure to restart TestComplete or any other application (for example, a file manager used to launch TestComplete from the command line) before you use the new variable.

  • TestComplete variables search order is as follows:

    • Project variables
    • Project suite variables
    • Environment variables

    Keep this in mind if you have project suite and project variables with the same name.

  • The TestedApps editor uses a subset of existing environment variables when generating possible path substitutions. You can customize this subset using the Environment variables to use in paths option in Tools | Options | Engines | Tested Applications.

See Also

About Tested Applications
TestedApps Editor
Project And Project Suite Variables
Using Environment Variables in Automated Tests
Avoiding Computer-Specific Settings

Highlight search results