AddNew Method

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

Description

The Jobs.AddNew method lets you create a new item in the job collection represented by the Jobs object.

Declaration

JobsObj.AddNew()

JobsObj An expression, variable or parameter that specifies a reference to a Jobs object
Result A Job object

Applies To

The method is applied to the following object:

Result Value

A Job object for the newly created item of the job collection.

Example

The code below creates a new job in a job collection, specifies a name for this job and then runs it at the end of the test.

JavaScript, JScript

function AddJobExample()
{
  // Obtains information about the job collection
  var colJobs = NetworkSuite.Jobs;
  // Adds a new job to the collection
  var NewJob = colJobs.AddNew();
  // Specifies a name for the created job
  NewJob.Name = "My_New_Job";
  
  // ...
  
  // Runs the created job
  NewJob.Run(true);
}

Python

def AddJobExample():
  # Obtains information about the job collection
  colJobs = NetworkSuite.Jobs
  # Adds a new job to the collection
  NewJob = colJobs.AddNew()
  # Specifies a name for the created job
  NewJob.Name = "My_New_Job"
  # ...
  # Runs the created job
  NewJob.Run(True)

VBScript

Sub AddJobExample()

  ' Obtains information about the job collection
  Set colJobs = NetworkSuite.Jobs
  ' Adds a new job to the collection
  Set NewJob = colJobs.AddNew
  ' Specifies a name for the created job
  NewJob.Name = "My_New_Job"
  
  ' ...
  
  ' Runs the created job
  NewJob.Run(true)
  
End Sub

DelphiScript

function AddJobExample;
var colJobs, NewJob;
begin

  // Obtains information about the job collection
  colJobs := NetworkSuite.Jobs;
  // Adds a new job to the collection
  NewJob := colJobs.AddNew;
  // Specifies a name for the created job
  NewJob.Name := 'My_New_Job';
  
  // ...
  
  // Runs the created job
  NewJob.Run(true);

end;

C++Script, C#Script

function AddJobExample()
{
  // Obtains information about the job collection
  var colJobs = NetworkSuite["Jobs"];
  // Adds a new job to the collection
  var NewJob = colJobs["AddNew"]();
  // Specifies a name for the created job
  NewJob["Name"] = "My_New_Job";
  
  // ...
  
  // Runs the created job
  NewJob["Run"](true);
}

See Also

Distributed Testing
Items Property
ItemByName Property
Count Property

Highlight search results