State Property

Applies to TestComplete 15.63, last modified on April 22, 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 State property returns the state of the given host.

Declaration

HostObj.State

Read-Only Property Integer
HostObj An expression, variable or parameter that specifies a reference to a Host object

Applies To

The property is applied to the following object:

Property Value

An integer value that stands for the host state. The following values are available:

Value Description
hsConnected The host is connected to the current computer.
hsDisconnected The host is disconnected from the current computer.

Example

For instance, you can check the state of a particular host before running a task on it:

JavaScript, JScript

function Test()
{
  var Task = NetworkSuite.Jobs.ItemByName("Job1").Tasks.ItemByName("Task1");
  if (Task.Host.State == hsConnected)
    Task.Run(true);
}

Python

def Test():
  Task = NetworkSuite.Jobs.ItemByName["Job1"].Tasks.ItemByName["Task1"]
  if Task.Host.State == hsConnected:
    Task.Run(True)

VBScript

Sub Test
  Set Task = NetworkSuite.Jobs.ItemByName("Job1").Tasks.ItemByName("Task1")
  If Task.Host.State = hsConnected Then
    Task.Run(True)
  End If
End Sub

DelphiScript

procedure Test;
var Task : OleVariant;
begin
  Task := NetworkSuite.Jobs.ItemByName['Job1'].Tasks.ItemByName['Task1'];
  if Task.Host.State = hsConnected then
    Task.Run(True);
end;

C++Script, C#Script

function Test()
{
  var Task = NetworkSuite["Jobs"]["ItemByName"]("Job1")["Tasks"]["ItemByName"]("Task1");
  if (Task["Host"]["State"] == hsConnected)
    Task["Run"](true);
}

See Also

Distributed Testing
Host.Verify

Highlight search results