NetworkSuite.Variables 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 Variables property returns the collection of local variables defined in the network suite. These are variables defined in the network suite’s master project. That is, even if the current project is a slave project, you can use the property to work with the master project’s variables.

Declaration

NetworkSuite.Variables

Read-Only Property A Variables object

Applies To

The property is applied to the following object:

Property Value

A Variables object that represents the collection of network suite variables defined in the current or master project.

Remarks

You cannot create new or delete existing network suite variables during the network suite run. An attempt to do this will result in an exception.

Example

The following example adds a new variable to the network suite variables collection and then runs the network suite. After the network suite execution is completed, it deletes the variable.

JavaScript

function NetworkSuiteSample()
{
  // Adds a new network suite variable
  if (! NetworkSuite.Variables.VariableExists("TotalFilesCount"))
    NetworkSuite.Variables.AddVariable("TotalFilesCount", "Integer");
  // Sets the variable’s value
  NetworkSuite.Variables.$set("VariableByName", "TotalFilesCount", 0);

  …
  NetworkSuite.Run(true);
  …

  // After the network suite stops, deletes the variable
  NetworkSuite.Variables.RemoveVariable("TotalFilesCount");
}

JScript

function NetworkSuiteSample()
{
  // Adds a new network suite variable
  if (! NetworkSuite.Variables.VariableExists("TotalFilesCount"))
    NetworkSuite.Variables.AddVariable("TotalFilesCount", "Integer");
  // Sets the variable’s value
  NetworkSuite.Variables.VariableByName("TotalFilesCount") = 0;

  …
  NetworkSuite.Run(true);
  …

  // After the network suite stops, deletes the variable
  NetworkSuite.Variables.RemoveVariable("TotalFilesCount");
}

Python

def NetworkSuiteSample():
  # Adds a new network suite variable 
  if not NetworkSuite.Variables.VariableExists("TotalFilesCount"):
    NetworkSuite.Variables.AddVariable("TotalFilesCount", "Integer")
  # Sets the variable's value 
  NetworkSuite.Variables.VariableByName["TotalFilesCount"] = 0
  NetworkSuite.Run(True)
  # After the network suite stops, deletes the variable 
  NetworkSuite.Variables.RemoveVariable("TotalFilesCount")

VBScript

Sub NetworkSuiteSample

  ' Adds a new network suite variable
  If Not NetworkSuite.Variables.VariableExists("TotalFilesCount") Then
    Call NetworkSuite.Variables.AddVariable("TotalFilesCount", "Integer")
  End If
  ' Sets the variable’s value
  NetworkSuite.Variables.VariableByName("TotalFilesCount") = 0

  …
  Call NetworkSuite.Run(True)
  …

  ' After the network suite stops, deletes the variable
  Call NetworkSuite.Variables.RemoveVariable("TotalFilesCount")
End Sub

DelphiScript

procedure NetworkSuiteSample();
begin
  // Adds a new network suite variable
  if not NetworkSuite.Variables.VariableExists('TotalFilesCount') then
    NetworkSuite.Variables.AddVariable('TotalFilesCount', 'Integer');
  // Sets the variable’s value
  NetworkSuite.Variables.VariableByName('TotalFilesCount') := 0;

  …
  NetworkSuite.Run(true);
  …

  // After the network suite stops, deletes the variable
  NetworkSuite.Variables.RemoveVariable('TotalFilesCount');
end;

C++Script, C#Script

function NetworkSuiteSample()
{
  // Adds a new network suite variable
  if (! NetworkSuite["Variables"]["VariableExists"]("TotalFilesCount"))
    NetworkSuite["Variables"]["AddVariable"]("TotalFilesCount", "Integer");
  // Sets the variable’s value
  NetworkSuite["Variables"]["VariableByName"]("TotalFilesCount") = 0;

  …
  NetworkSuite["Run"](true);
  …

  // After the network suite stops, deletes the variable
  NetworkSuite["Variables"]["RemoveVariable"]("TotalFilesCount");
}

See Also

Distributed Testing
Network Suite Variables
Variables Object
Variables Property
Variables Property

Highlight search results