NetworkSuite.Hosts Property

Applies to TestComplete 15.47, last modified on January 20, 2023
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 property returns the host collection specified in the network suite that belongs to the current project.

Declaration

NetworkSuite.Hosts

Read-Only Property The Hosts object

Applies To

The property is applied to the following object:

Property Value

The Hosts object that represents the collection of hosts defined in the network suite of the current project.

Example

The following code obtains the collection of hosts, iterates through its items, verifies each host in the collection and posts information on the hosts to the test log.

JavaScript, JScript

function NetworkSuiteSample()
{
  var Hosts, Host;
  // Obtains the collection of hosts
  Hosts = NetworkSuite.Hosts;

  // Iterates through the hosts
  for (var i = 0; i < Hosts.Count; i++)
  {
    // Obtains the current host
    Host = Hosts.Items(i);
    // Posts the host name to the test log
    Log.AppendFolder(Host.Name);
    // Verifies the host and posts verification results to the test log
    if (Host.Verify())
      Log.Message("The " + Host.Name + " host has passed the verification");
    else
      Log.Warning("The host verification has failed")
    // Posts information on the current host to the test log
    Log.Message("Address: " + Host.Address);
    Log.Message("User account: " + Host.Domain + "\\" + Host.UserName);
    Log.Message("Password: " + Host.Password);
    Log.PopLogFolder();
  }

}

Python

def NetworkSuiteSample():
  # Obtains the collection of hosts
  Hosts = NetworkSuite.Hosts
  # Iterates through the hosts
  for i in range(0, Hosts.Count):
    # Obtains the current host
    Host = Hosts.Items[i]
    # Posts the host name to the test log
    Log.AppendFolder(Host.Name)
    # Verifies the host and posts verification results to the test log
    if Host.Verify():
      Log.Message("The " + Host.Name + " host has passed the verification")
    else:
      Log.Warning("The host verification has failed")
    # Posts information on the current host to the test log
    Log.Message("Address: " + Host.Address)
    Log.Message("User account: " + Host.Domain + "\\" + Host.UserName)
    Log.Message("Password: " + Host.Password)
    Log.PopLogFolder()

VBScript

Sub NetworkSuiteSample

  ' Obtains the collection of hosts
  Set Hosts = NetworkSuite.Hosts

  ' Iterates through the hosts
  For i = 0 To Hosts.Count - 1
    ' Obtains the current host
    Set Host = Hosts.Items(i)
    ' Posts the host name to the test log
    Log.AppendFolder Host.Name
    ' Verifies the host and posts verification results to the test log
    If Host.Verify Then
      Log.Message "The " & Host.Name & " host has passed the verification"
    Else
      Log.Warning "The host verification has failed"
    End If
    ' Posts information on the current host to the test log
    Log.Message "Address: " & Host.Address
    Log.Message "User account: " & Host.Domain & "\" & Host.UserName
    Log.Message "Password: " & Host.Password
    Log.PopLogFolder
  Next

End Sub

DelphiScript

procedure NetworkSuiteSample();
var Hosts, Host, i;
begin
  // Obtains the collection of hosts
  Hosts := NetworkSuite.Hosts;

  // Iterates through the hosts
  for i := 0 to Hosts.Count - 1 do
  begin
    // Obtains the current host
    Host := Hosts.Items[i];
    // Posts the host name to the test log
    Log.AppendFolder(Host.Name);
    // Verifies the host and posts verification results to the test log
    if Host.Verify then
      Log.Message('The ' + Host.Name + ' host has passed the verification')
    else
      Log.Warning('The host verification has failed');
    // Posts information on the current host to the test log
    Log.Message('Address: ' + Host.Address);
    Log.Message('User account: ' + Host.Domain + '\' + Host.UserName);
    Log.Message('Password: ' + Host.Password);
    Log.PopLogFolder;
  end;

end;

C++Script, C#Script

function NetworkSuiteSample()
{
  var Hosts, Host;
  // Obtains the collection of hosts
  Hosts = NetworkSuite["Hosts"];

  // Iterates through the hosts
  for (var i = 0; i < Hosts.Count; i++)
  {
    // Obtains the current host
    Host = Hosts["Items"](i);
    // Posts the host name to the test log
    Log["AppendFolder"](Host["Name"]);
    // Verifies the host and posts verification results to the test log
    if (Host["Verify"]())
      Log.Message("The " + Host["Name"] + " host has passed the verification");
    else
      Log["Warning"]("The host verification has failed")
    // Posts information on the current host to the test log
    Log["Message"]("Address: " + Host["Address"]);
    Log["Message"]("User account: " + Host["Domain"] + "\\" + Host["UserName"]);
    Log["Message"]("Password: " + Host["Password"]);
    Log["PopLogFolder"]();
  }

}

See Also

Distributed Testing
Editing Host Properties
Hosts Object
NetworkSuite.Jobs
NetworkSuite.Variables

Highlight search results