AddNew Method

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 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