Items Property

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 Items property returns a task specified by its index in the task collection represented by the Tasks object.

Declaration

TasksObj.Items(Index)

Read-Only Property A Task object
TasksObj An expression, variable or parameter that specifies a reference to a Tasks object
Index [in]    Required    Integer    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

Index

The index of the desired task in the task collection. The index ranges between 0 and Tasks.Count - 1.

Property Value

A Task object.

Remarks

If you use Python or DelphiScript, you should enclose the parameter of the Items property in square brackets: Items[Index].

Since the Items property is the default property for the Tasks object, you can omit the name of this property when referring to a collection item. Thus, the following code lines are equivalent:

JavaScript, JScript

// Using the Items property explicitly
Task = NetworkSuite.Jobs(0).Tasks.Items(0);
// Using the Items property implicitly
Task = NetworkSuite.Jobs(0).Tasks(0);

Python

# Using the Items property explicitly 
Task = NetworkSuite.Jobs[0].Tasks.Items[0]
# Using the Items property implicitly
Task = NetworkSuite.Jobs[0].Tasks[0]

VBScript

' Using the Items property explicitly
Set Task = NetworkSuite.Jobs(0).Tasks.Items(0)
' Using the Items property implicitly
Set Task = NetworkSuite.Jobs(0).Tasks(0)

DelphiScript

// Using the Items property explicitly
Task := NetworkSuite.Jobs[0].Tasks.Items[0];
// Using the Items property implicitly
Task := NetworkSuite.Jobs[0].Tasks[0];

C++Script, C#Script

// Using the Items property explicitly
Task = NetworkSuite["Jobs"](0)["Tasks"]["Items"](0);
// Using the Items property implicitly
Task = NetworkSuite["Jobs"](0)["Tasks"](0);

Example

The following example obtains a task by its index and runs it.

JavaScript, JScript

function Test()
{

  var JobName, Tasks, Indx, Task;
  // Specifies the name of the job to which the task belongs
  JobName = "Job1";
  // Specifies the task’s index
  Indx = 0;
  // Obtains the tasks that belong to the specified job
  Tasks = NetworkSuite.Jobs.ItemByName(JobName).Tasks;
  // Obtains the task by its index
  Task = Tasks.Items(Indx);
  Task.Run(true);

}

Python

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

VBScript

Sub Test

  Dim JobName, Tasks, Indx, Task
  ' Specifies the name of the job to which the task belongs
  JobName = "Job1"
  ' Specifies the task’s index
  Indx = 0
  ' Obtains the tasks that belong to the specified job
  Set Tasks = NetworkSuite.Jobs.ItemByName(JobName).Tasks
  ' Obtains the task by its index
  Set Task = Tasks.Items(Indx)
  Task.Run(True)

End Sub

DelphiScript

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

  // Specifies the name of the job to which the task belongs
  JobName := 'Job1';
  // Specifies the task’s index
  Indx := 0;
  // Obtains the tasks that belong to the specified job
  Tasks := NetworkSuite.Jobs.ItemByName(JobName).Tasks;
  // Obtains the task by its index
  Task := Tasks.Items[Indx];
  Task.Run(true);

end;

C++Script, C#Script

function Test()
{

  var JobName, Tasks, Indx, Task;
  // Specifies the name of the job to which the task belongs
  JobName = "Job1";
  // Specifies the task’s index
  Indx = 0;
  // Obtains the tasks that belong to the specified job
  Tasks = NetworkSuite["Jobs"]["ItemByName"](JobName)["Tasks"];
  // Obtains the task by its index
  Task = Tasks["Items"](Indx);
  Task["Run"](true);

}

See Also

Distributed Testing
Tasks.Count
Tasks.ItemByName
Task Object
Task.Index

Highlight search results