NetworkSuite.Variables Property

Applies to TestComplete 14.30, last modified on November 21, 2019

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
Project.Variables Property
ProjectSuite.Variables Property

Highlight search results