Tasks Object

Applies to TestComplete 15.70, last modified on December 17, 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 Tasks object represents a collection of tasks specified in a particular job of the given network suite (see Editing Task Properties). Each task is represented by a Task object.

To get the Tasks object, use the Job.Tasks property.

Members

Example

The following code snippet obtains a task and runs it.

JavaScript, JScript

function Test()
{

  var JobName, Tasks, TaskName, Task;
  // Specifies the name of the job to which the task belongs
  JobName = "Job1";
  // Specifies the name of the needed task
  TaskName = "Task1";
  // Obtains the tasks that belong to the specified job
  Tasks = NetworkSuite.Jobs.ItemByName(JobName).Tasks;
  // Obtains the task by its name
  Task = Tasks.ItemByName(TaskName);
  Task.Run(true);

}

Python

def Test():
  # Specifies the name of the job to which the task belongs 
  JobName = "Job1"
  # Specifies the name of the needed task 
  TaskName = "Task1"
  # Obtains the tasks that belong to the specified job 
  Tasks = NetworkSuite.Jobs.ItemByName[JobName].Tasks
  # Obtains the task by its name
  Task = Tasks.ItemByName[TaskName]
  Task.Run(True)

VBScript

Sub Test

  Dim JobName, Tasks, TaskName, Task
  ' Specifies the name of the job to which the task belongs
  JobName = "Job1"
  ' Specifies the name of the needed task
  TaskName = "Task1"
  ' Obtains the tasks that belong to the specified job
  Set Tasks = NetworkSuite.Jobs.ItemByName(JobName).Tasks
  ' Obtains the task by its name
  Set Task = Tasks.ItemByName(TaskName)
  Task.Run(True)

End Sub

DelphiScript

procedure Test();
var JobName, Tasks, TaskName, Task;
begin

  // Specifies the name of the job to which the task belongs
  JobName := 'Job1';
  // Specifies the name of the needed task
  TaskName := 'Task1';
  // Obtains the tasks that belong to the specified job
  Tasks := NetworkSuite.Jobs.ItemByName[JobName].Tasks;
  // Obtains the task by its name
  Task := Tasks.ItemByName[TaskName];
  Task.Run(true);

end;

C++Script, C#Script

function Test()
{

  var JobName, Tasks, TaskName, Task;
  // Specifies the name of the job to which the task belongs
  JobName = "Job1";
  // Specifies the name of the needed task
  TaskName = "Task1";
  // Obtains the tasks that belong to the specified job
  Tasks = NetworkSuite["Jobs"]["ItemByName"](JobName)["Tasks"];
  // Obtains the task by its name
  Task = Tasks["ItemByName"](TaskName);
  Task["Run"](true);

}

See Also

Distributed Testing
Editing Task Properties
Job.Tasks
Task Object

Highlight search results