Job Object

Applies to TestComplete 15.47, last modified on January 20, 2023
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 Job object represents one of the jobs specified in the current project’s network suite (see Editing Job Properties). You obtain a job as an item in the collection of jobs (see Jobs Object). Each job can hold a collection of tasks (see Tasks Object).

Members

Example

The code below obtains all the tasks that belong to the specified job and then posts the names of these tasks to the test log.

JavaScript, JScript

function TasksNamesExample()
{
  // Specifies the name of a job
  var jName = "Job_Name";
  // Obtains information about the job
  var Job = NetworkSuite.Jobs.ItemByName(jName);
  // Obtains the tasks that belong to the job
  var Tasks = Job.Tasks;
  // Obtains the number of tasks
  var Num = Tasks.Count;
  
  // Iterates through the tasks
  for (var i = 0; i < Num; i++)
  {
    // Obtains the current item
    var Task = Tasks.Items(i);
    var Name = Task.Name;
    // Posts the task's name to the test log
    Log.Message(Name);
  }
}

Python

def TasksNamesExample():
  # Specifies the name of a job
  jName = "Job_Name"
  # Obtains information about the job
  Job = NetworkSuite.Jobs.ItemByName[jName]
  # Obtains the tasks that belong to the job
  Tasks = Job.Tasks
  # Obtains the number of tasks
  Num = Tasks.Count
  # Iterates through the tasks
  for i in range (0, Num):
    # Obtains the current item
    Task = Tasks.Items[i]
    Name = Task.Name
    # Posts the task's name to the test log
    Log.Message(Name)

VBScript

Sub TasksNamesExample()

  ' Specifies the name of a job
  jName = "Job_Name"
  ' Obtains information about the job
  Set Job = NetworkSuite.Jobs.ItemByName(jName)
  ' Obtains the tasks that belong to the job
  Set Tasks = Job.Tasks
  ' Obtains the number of tasks
  Num = Tasks.Count
  
  ' Iterates through the tasks
  For i = 0 to (Num - 1)
    ' Obtains the current item
    Set Task = Tasks.Items(i)
    Name = Task.Name
    ' Posts the task's name to the test log
    Log.Message(Name)
  Next
     
End Sub

DelphiScript

function TasksNamesExample;
var jName, Job, Tasks, Num, i, Task, Name;
begin

  // Specifies the name of a job
  jName := 'Job_Name';
  // Obtains information about the job
  Job := NetworkSuite.Jobs.ItemByName[jName];
  // Obtains the tasks that belong to the job
  Tasks := Job.Tasks;
  // Obtains the number of tasks
  Num := Tasks.Count;
  
  // Iterates through the tasks
  for i := 0 to (Num - 1) do
  begin
    // Obtains the current item
    Task := Tasks.Items[i];
    Name := Task.Name;
    // Posts the task's name to the test log
    Log.Message(Name);
  end;

end;

C++Script, C#Script

function TasksNamesExample()
{
  // Specifies the name of a job
  var jName = "Job_Name";
  // Obtains information about the job
  var Job = NetworkSuite["Jobs"]["ItemByName"](jName);
  // Obtains the tasks that belong to the job
  var Tasks = Job["Tasks"];
  // Obtains the number of tasks
  var Num = Tasks["Count"];
  
  // Iterates through the tasks
  for (var i = 0; i < Num; i++)
  {
    // Obtains the current item
    var Task = Tasks["Items"](i);
    var Name = Task["Name"];
    // Posts the task's name to the test log
    Log["Message"](Name);
  }
}

See Also

Distributed Testing
Working With Jobs
Jobs Object
Items Property
ItemByName Property
Tasks Object

Highlight search results