ActionAfterRun Property

Applies to TestComplete 15.44, last modified on November 10, 2022
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 ActionAfterRun property returns a value that specifies the action that will be performed after the task execution on the specified host is completed (see the Action after run property of the task).

Declaration

TaskObj.ActionAfterRun

Read-Write Property Integer
TaskObj An expression, variable or parameter that specifies a reference to a Task object

Applies To

The property is applied to the following object:

Property Value

An integer value that stands for the assigned action. The following values are available:

Value Description
saNone Do nothing (does not close TestComplete).
saClose Close TestComplete.
saLogOff Log off from the host computer (Task.Host).
saReboot Reboot the host computer (Task.Host).
saShutDown Shut down the host computer (Task.Host).

Example

The following code snippet obtains the task by its name, specifies its properties, sets the action that will be performed after the task execution is completed and launches the task.

JavaScript, JScript

function Test()
{

  var Task, TaskName;
  // Specifies a name for the task
  TaskName = "MyTask";
  // Obtains the task by its name task
  Task = NetworkSuite.Jobs.ItemByName("MyJob").Tasks.ItemByName(TaskName);

  // Specifies that TestComplete on the remote host will be closed after the task is executed
  Task.ActionAfterRun = saClose;
  // Specifies the host on which the task will be run
  Task.Host = NetworkSuite.Hosts.ItemByName("SlaveComputer1");

  // Specifies the path to the project the task will run
  Task.ProjectPath = "D:\\Distributed Testing\\Slave\\SlaveProject.mds";
  // Specifies the test item the task will run
  Task.Test = "Slave_Script\\Script\\Slave\Main";

  // Runs the task
  Task.Run(true);
}

Python

def Test():
  # Specifies a name for the task
  TaskName = "MyTask"
  # Obtains the task by its name task
  Task = NetworkSuite.Jobs.ItemByName["MyJob"].Tasks.ItemByName[TaskName]
  # Specifies that TestComplete on the remote host will be closed after the task is executed
  Task.ActionAfterRun = saClose
  # Specifies the host on which the task will be run
  Task.Host = NetworkSuite.Hosts.ItemByName["SlaveComputer1"]
  # Specifies the path to the project the task will run
  Task.ProjectPath = "D:\\Distributed Testing\\Slave\\SlaveProject.mds"
  # Specifies the test item the task will run
  Task.Test = "Slave_Script\\Script\\Slave\\Main"
  # Runs the task
  Task.Run(True)

VBScript

Sub Test

  Dim Task, TaskName
  ' Specifies a name for the task
  TaskName = "MyTask"
  ' Obtains the task by its name task
  Set Task = NetworkSuite.Jobs.ItemByName("MyJob").Tasks.TaskByName(TaskName)

  ' Specifies that TestComplete on the remote host will be closed after the task is executed
  Task.ActionAfterRun = saClose
  ' Specifies the host on which the task will be run
  Set Task.Host = NetworkSuite.Hosts.ItemByName("SlaveComputer1")

  ' Specifies the path to the project the task will run
  Task.ProjectPath = "D:\Distributed Testing\Slave\SlaveProject.mds"
  ' Specifies the test item the task will run
  Task.Test = "Slave_Script\Script\Slave\Main"

  ' Runs the task
  Task.Run(True)
End Sub

DelphiScript

procedure Test();
var Task, TaskName;
begin

  // Specifies a name for the task
  TaskName := 'MyTask';
  // Obtains the task by its name task
  Task := NetworkSuite.Jobs.ItemByName['MyJob'].Tasks.ItemByName[TaskName];

  // Specifies that TestComplete on the remote host will be closed after the task is executed
  Task.ActionAfterRun := saClose;
  // Specifies the host on which the task will be run
  Task.Host := NetworkSuite.Hosts.ItemByName['SlaveComputer1'];

  // Specifies the path to the project the task will run
  Task.ProjectPath := 'D:\Distributed Testing\Slave\SlaveProject.mds';
  // Specifies the test item the task will run
  Task.Test := 'Slave_Script\Script\Slave\Main';

  // Runs the task
  Task.Run(true);
end;

C++Script, C#Script

function Test()
{

  var Task, TaskName;
  // Specifies a name for the task
  TaskName = "MyTask";
  // Obtains the task by its name task
  Task = NetworkSuite["Jobs"]["ItemByName"]("MyJob")["Tasks"]["ItemByName"](TaskName);

  // Specifies that TestComplete on the remote host will be closed after the task is executed
  Task["ActionAfterRun"] = saClose;
  // Specifies the host on which the task will be run
  Task["Host"] = NetworkSuite["Hosts"]["ItemByName"]("SlaveComputer1");

  // Specifies the path to the project the task will run
  Task["ProjectPath"] = "D:\\Distributed Testing\\Slave\\SlaveProject.mds";
  // Specifies the test item the task will run
  Task["Test"] = "Slave_Script\\Script\\Slave\\Main";

  // Runs the task
  Task["Run"](true);
}

See Also

Distributed Testing
Run Method
Host Property
PriorInstanceMode Property
CopyRemoteLogMode Property

Highlight search results