Hosts Object

Applies to TestComplete 15.69, last modified on November 13, 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 Hosts object represents a collection of hosts specified in the network suite of the current project (See Editing Host Properties). Each host is represented by a Host object.

To get the Hosts object, use the NetworkSuite.Hosts property.

Members

Example

The code below obtains the host collection of your project and then verifies the properties of each host in this collection.

JavaScript, JScript

function HostsDemo()
{
  // Obtains the number of hosts in the collection
  var Num = NetworkSuite.Hosts.Count;
  
  // Iterates through the host collection
  for (var i = 0; i < Num; i++)
  {
    // Obtains the current host
    var Item = NetworkSuite.Hosts.Items(i);
    // Gets the name of the current host
    var Name = Item.Name;
    // Verifies the current host
    if (Item.Verify)
      Log.Message("The " + Name + " host can be used by a network suite.")
    else
      Log.Message("The " + Name + " host can't be used by a network suite.");
  }
  
}

Python

def HostsDemo():
  # Obtains the number of hosts in the collection
  Num = NetworkSuite.Hosts.Count
  # Iterates through the host collection
  for i in range (0, Num):
    # Obtains the current host
    Item = NetworkSuite.Hosts.Items[i]
    # Gets the name of the current host
    Name = Item.Name
    # Verifies the current host
    if Item.Verify:
      Log.Message("The " + Name + " host can be used by a network suite.")
    else:
      Log.Message("The " + Name + " host can't be used by a network suite.")

VBScript

Sub HostsDemo()

  ' Obtains the number of hosts in the collection
  Num = NetworkSuite.Hosts.Count
  
  ' Iterates through the host collection
  For i = 0 to (Num-1)
    ' Obtains the current host
    Set Item = NetworkSuite.Hosts.Items(i)
    ' Gets the name of the current host
    Name = Item.Name
    ' Verifies the current host
    If Item.Verify Then
      Log.Message("The " & Name & " host can be used by a network suite.")
    Else
      Log.Message("The " & Name & " host can't be used by a network suite.")
    End If
  Next
  
End Sub

DelphiScript

function HostsDemo;
var Num, i, Item, Name;
begin

  // Obtains the number of hosts in the collection
  Num := NetworkSuite.Hosts.Count;
  
  // Iterates through the host collection
  for i := 0 to (Num - 1) do
  begin
    // Obtains the current host
    Item := NetworkSuite.Hosts.Items[i];
    // Gets the name of the current host
    Name := Item.Name;
    // Verifies the current host
    if (Item.Verify) then
      Log.Message('The ' + Name + ' host can be used by a network suite.')
    else
      Log.Message('The ' + Name + ' host can''t be used by a network suite.');
  end;
  
end;

C++Script, C#Script

function HostsDemo()
{
  // Obtains the number of hosts in the collection
  var Num = NetworkSuite["Hosts"]["Count"];
  
  // Iterates through the host collection
  for (var i = 0; i < Num; i++)
  {
    // Obtains the current host
    var Item = NetworkSuite["Hosts"]["Items"](i);
    // Gets the name of the current host
    var Name = Item["Name"];
    // Verifies the current host
    if ( Item["Verify"] )
      Log["Message"]("The " + Name + " host can be used by a network suite.")
    else
      Log["Message"]("The " + Name + " host can't be used by a network suite.");
  }
  
}

See Also

Distributed Testing
Editing Host Properties
Hosts Property
Host Object

Highlight search results