ProjectPath Property

Applies to TestComplete 15.68, last modified on October 03, 2024
The Network Suite functionality is deprecated. We don’t recommend using it for distributed testing. Consider using a CI/CD system for managing distributed tests. See Migrating Distributed Tests to CI/CD Systems for details. In case you need to run web tests on multiple environments in parallel, you can also try using your project’s Execution Plan.

Description

The ProjectPath property specifies the name (with the path) of the TestComplete project or project suite the given task will run. The property provides scripting access to the Project file name property of the task you can specify in the Tasks editor.

Note that the path you specify to the target project or project suite must be relative to the remote computer where the task will be executed (to obtain the computer name, use the Task.Host property). If the BasePath property of the remote computer specifies a folder on that computer, the value of the ProjectPath property must be relative to that folder. The full name of the project or project suite to be executed is specified as concatenation of the Host.BasePath property value and the Task.ProjectPath property value.

If the ProjectPath property is not specified (empty string), the name of the project suite to be executed on the remote host is considered the same as the name of the current project suite.

Declaration

TaskObj.ProjectPath

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

Applies To

The property is applied to the following object:

Property Value

A string that represents the path to the TestComplete project or project suite on the remote machine.

Remarks

If the BasePath property of the assigned host specifies the fully qualified name (not recommended) with the full path of the project or project suite to be executed on the remote computer and the ProjectPath property is not specified, the path to the project or project suite to be executed is specified by the BasePath property only and the default value of the ProjectPath property is not used.

If you want several tasks that run on different hosts to use the same slave project, copy the project (project suite) to each slave host rather than use a common shared project (project suite). It is not recommended to use a common shared project (project suite) for several hosts, since slave hosts may fail to open the shared project (project suite) simultaneously. For more information on copying projects, see Copying Slave Projects to Remote Computers.

Example

The following code snippet obtains a task by its name, specifies the host on which the task will be run, sets the path to the project and specifies the test item that will be executed by the task. After that, it runs the specified task.

JavaScript, JScript

function Test()
{
  var JobName, TaskName, Task;
  // Specifies the name for the job to which the task belongs
  JobName = "MyJob";
  // Specifies the name of the task
  TaskName = "MyTask";
  // Obtains the task by its name
  Task = NetworkSuite.Jobs.ItemByName(JobName).Tasks.ItemByName(TaskName);

  // Specifies the host on which the task will be run
  Task.Host = NetworkSuite.Hosts.ItemByName("SlaveComputer1");

  // Specifies the path to the project the task will run
  Task.ProjectPath = "D:\\Distributed Testing\\Slave\\SlaveProject.mds";
  // Specifies the test item the task will run
  Task.Test = "Slave_Script\\Script\\Slave\\Main";

  // Runs the task
  Task.Run(true);
}

Python

def Test():
  # Specifies the name for the job to which the task belongs
  JobName = "MyJob"
  # Specifies the name for the task
  TaskName = "MyTask"
  # Obtains the task by its name
  Task = NetworkSuite.Jobs.ItemByName[JobName].Tasks.ItemByName[TaskName]
  # Specifies the host on which the task will be run
  Task.Host = NetworkSuite.Hosts.ItemByName["SlaveComputer1"]
  # Specifies the path to the project the task will run
  Task.ProjectPath = "D:\\Distributed Testing\\Slave\\SlaveProject.mds"
  # Specifies the test item the task will run
  Task.Test = "Slave_Script\\Script\\Slave\\Main"
  # Runs the task
  Task.Run(True)

VBScript

Sub Test

  Dim JobName, TaskName, Task
  ' Specifies the name for the job to which the task belongs
  JobName = "MyJob"
  ' Specifies the name of the task
  TaskName = "MyTask"
  ' Obtains the task by its name
  Set Task = NetworkSuite.Jobs.ItemByName(JobName).Tasks.ItemByName(TaskName)

  ' Specifies the host on which the task will be run
  Set Task.Host = NetworkSuite.Hosts.ItemByName("SlaveComputer1")

  ' Specifies the path to the project the task will run
  Task.ProjectPath = "D:\Distributed Testing\Slave\SlaveProject.mds"
  ' Specifies the test item the task will run
  Task.Test = "Slave_Script\Script\Slave\Main"

  ' Runs the task
  Task.Run(True)
End Sub

DelphiScript

procedure Test();
var JobName, TaskName, Task;
begin
  // Specifies the name for the job to which the task belongs
  JobName := 'MyJob';
  // Specifies the name of the task
  TaskName := 'MyTask';
  // Obtains the task by its name
  Task := NetworkSuite.Jobs.ItemByName[JobName].Tasks.ItemByName[TaskName];

  // Specifies the host on which the task will be run
  Task.Host := NetworkSuite.Hosts.ItemByName['SlaveComputer1'];

  // Specifies the path to the project the task will run
  Task.ProjectPath := 'D:\Distributed Testing\Slave\SlaveProject.mds';
  // Specifies the test item the task will run
  Task.Test := 'Slave_Script\Script\Slave\Main';

  // Runs the task
  Task.Run(true);
end;

C++Script, C#Script

function Test()
{
  var JobName, TaskName, Task;
  // Specifies the name for the job to which the task belongs
  JobName = "MyJob";
  // Specifies the name of the task
  TaskName = "MyTask";
  // Obtains the task by its name
  Task = NetworkSuite["Jobs"]["ItemByName"](JobName)["Tasks"]["ItemByName"](TaskName);

  // Specifies the host on which the task will be run
  Task["Host"] = NetworkSuite["Hosts"]["ItemByName"]("SlaveComputer1");

  // Specifies the path to the project the task will run
  Task["ProjectPath"] = "D:\\Distributed Testing\\Slave\\SlaveProject.mds";
  // Specifies the test item the task will run
  Task["Test"] = "Slave_Script\\Script\\Slave\\Main";

  // Runs the task
  Task["Run"](true);
}

See Also

Distributed Testing
Task.Run
Task.Test
Task.Host
Host.BasePath
NetworkSuite.SharedPath

Highlight search results