Tasks Object

Applies to TestComplete 14.61, last modified on April 22, 2021

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