Job Object

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

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