Path Property

Applies to TestComplete 15.40, last modified on March 25, 2022

Description

The TestedApp.Path property specifies the path to the folder that contains the executable or batch file of the given tested application.

Note: This property is meaningful only for generic Windows applications run in the Simple, RunAs, Profile or Debug mode.

Declaration

TestedAppObj.Path

Read-Write Property String
TestedAppObj An expression, variable or parameter that specifies a reference to a TestedApp object

Applies To

The property is applied to the following object:

Property Value

The path to the folder that holds the tested application’s file.

Remarks

The path returned by the property, includes a trailing slash ("\").

To specify the path, you can use project and project suite variables and also Windows environment variables. These variables must be a string type. Within the string specifying the path, the environment variable name must be enclosed in % signs, for example, “%USERPROFILE%”, “%WINDIR%”, “%SYSTEMROOT%”. Names of the project or project suite variable must be enclosed in parenthesis and follow the $ sign, for example, “$(PathToApp)”.

If the path includes environment variables, TestComplete does not expose the real path when you obtain the Path property value.

Note: A new environment variable becomes available to applications that were launched after the variable creation. It is not seen in applications launched before the creation. Make sure you have restarted TestComplete or any other application (for example, a file manager used to launch TestComplete from command line) before you try to work with the new variable.
When evaluating the value of the Path property, TestComplete searches for the specified variable in the following order:
  • Project variables
  • Project suite variables
  • Environment variables
Keep this in mind if you have project suite and project variables with the same name.

The application path is a computer-specific setting and it may cause problems if you move your project to another workstation or if you share the project among other testers, because on other computers the path may point to a non-existing location. To make the tested application’s settings computer-independent, use the relative path to the application, if possible. If you share the project among several testers, place the application in a shared folder and assign the application’s network path to the Path property. This will help other testers working with the project avoid problems with the application’s path. See Computer-Specific Settings for more information.

Example

The following example demonstrates how you can change the path to the tested application’s executable file in script.

JavaScript, JScript

function Test()
{

  var SampleApp, FileName, Path;
  // Obtains the tested application
  SampleApp = TestedApps.Items("SampleApp");
  // Specifies the path to the executable
  Path = "D:\\Work Folder\\Applications";
  SampleApp.Path = Path;
  // Launches the tested application
  SampleApp.Run();

}

Python

def Test():
  # Obtains the tested application
  SampleApp = TestedApps.Items["SampleApp"]
  # Specifies the path to the executable
  Path = "D:\\Work Folder\\Applications"
  SampleApp.Path = Path
  # Launches the tested application
  SampleApp.Run()

VBScript

Sub Test

  Dim SampleApp, FileName, Path
  ' Obtains the tested application
  Set SampleApp = TestedApps.Items("SampleApp")
  ' Specifies the path to the executable
  Path = "D:\Work Folder\Applications"
  SampleApp.Path = Path
  ' Launches the tested application
  SampleApp.Run

End Sub

DelphiScript

procedure Test();
var SampleApp, FileName, Path;
begin

  // Obtains the tested application
  SampleApp := TestedApps.Items('SampleApp');
  // Specifies the path to the executable
  Path := 'D:\Work Folder\Applications';
  SampleApp.Path := Path;
  // Launches the tested application
  SampleApp.Run;

end;

C++Script, C#Script

function Test()
{

  var SampleApp, FileName, Path;
  // Obtains the tested application
  SampleApp = TestedApps["Items"]("SampleApp");
  // Specifies the path to the executable
  Path = "D:\\Work Folder\\Applications";
  SampleApp["Path"] = Path;
  // Launches the tested application
  SampleApp["Run"]();

}

See Also

ItemName Property
FileName Property
FullFileName Property
Run Method
RunAll Method
Avoiding Computer-Specific Settings

Highlight search results