State Property

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

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