ItemByName 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 Items property returns a host specified by the name it has in the host collection represented by the Hosts object.

Declaration

HostsObj.ItemByName(Name)

Read-Only Property A Host object
HostsObj An expression, variable or parameter that specifies a reference to a Hosts object
Name [in]    Required    String    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

Name

The unique name of the desired host in the host collection.

Property Value

A Host object.

Remarks

If you use Python or DelphiScript, you should enclose the parameter of the ItemByName property in square brackets: ItemByName[Name].

Example

The code below demonstrates how you can get access to the desired host by its name using the ItemByName property and then use the resulting Host object to copy a project to a slave computer.

JavaScript, JScript

function ItemByNameDemo()
{
  // Gets access to the host by its name
  var Host = NetworkSuite.Hosts.ItemByName("SlaveComputer1");
  // Copies a project to the SlaveComputer1 computer
  Host.CopyProjectToSlave();
  // Runs the network suite
  NetworkSuite.Run(true);
}

Python

def ItemByNameDemo():
  # Gets access to the host by its name
  Host = NetworkSuite.Hosts.ItemByName["SlaveComputer1"]
  # Copies a project to the SlaveComputer1 computer
  Host.CopyProjectToSlave()
  # Runs the network suite
  NetworkSuite.Run(True)

VBScript

Sub ItemByNameDemo()
  ' Gets access to the host by its name
  Set Host = NetworkSuite.Hosts.ItemByName("SlaveComputer1")
  ' Copies a project to the SlaveComputer1 computer
  Host.CopyProjectToSlave
  ' Runs the network suite
  NetworkSuite.Run(true)
End Sub

DelphiScript

function ItemByNameDemo;
var Host;
begin
  // Gets access to the host by its name
  Host := NetworkSuite.Hosts.ItemByName('SlaveComputer1');
  // Copies a project to the SlaveComputer1 computer
  Host.CopyProjectToSlave;
  // Runs the network suite
  NetworkSuite.Run(true);
end;

C++Script, C#Script

function ItemByNameDemo()
{
  // Gets access to the host by its name
  var Host = NetworkSuite["Hosts"]["ItemByName"]("SlaveComputer1");
  // Copies a project to the SlaveComputer1 computer
  Host["CopyProjectToSlave"]();
  // Runs the network suite
  NetworkSuite["Run"](true);
}

See Also

Distributed Testing
Hosts.Count
Hosts.Items
Hosts.AddNew
Host Object
Host.Name

Highlight search results