VariableCount Property

Applies to TestComplete 14.0, last modified on January 23, 2019

The object-driven testing (ODT) functionality is deprecated. Do not use it to create new tests. It will be removed from the product in one of the future releases. As an alternative, you can create custom classes in your scripts. For more information, see Alternatives to the ODT functionality.

Description

Use the Group.VariableCount property to get the total number of variables in the Group group.

Declaration

GroupObj.VariableCount

Read-Only Property Integer
GroupObj An expression, variable or parameter that specifies a reference to a Group object

Applies To

The property is applied to the following object:

Property Value

The total number of variables in the group.

Example

The code below obtains the collection of variables that belong to the MyGroup_Name group and posts both variable names and values to the test log.

JavaScript, JScript

function GroupVariables()
{
  // Obtains information about the group
  var Group = ODT.Data.MyGroup_Name;
  
  // Iterates through the variables
  for (var i = 0; i < Group.VariableCount; i++)
  {
    var Variable = Group.Variables(i);
    // Variable name
    var Name = Variable.Name;
    // Variable value
    var Value = Variable.Value;
    // Posts both the variable name and value to the test log
    Log.Message("The " + Name + " variable has the " + Value + " value.");
  }
}

VBScript

Sub GroupVariables
  ' Obtains information about the group
  Set Group = ODT.Data.MyGroup_Name
  
  ' Iterates through the variables
  For i = 0 to (Group.VariableCount - 1)
    Set Variable = Group.Variables(i)
    ' Variable name
    Name = Variable.Name
    ' Variable value
    Value = Variable.Value
    ' Posts both the variable name and value to the test log
    Log.Message("The " & Name & " variable has the " & Value & " value.")
  Next
End Sub

DelphiScript

function GroupVariables;
var Group, i, Variable, Name, Value;
begin

  // Obtains information about the group
  Group := ODT.Data.MyGroup_Name;
  
  // Iterates through the variables
  for i := 0 to (Group.VariableCount - 1) do
  begin
    Variable := Group.Variables[i];
    // Variable name
    Name := Variable.Name;
    // Variable value
    Value := Variable.Value;
    // Posts both the variable name and value to the test log
    Log.Message('The ' + Name + ' variable has the ' + Value + ' value.');
  end;
end;

C++Script, C#Script

function GroupVariables()
{
  // Obtains information about the group
  var Group = ODT["Data"]["MyGroup_Name"];
  
  // Iterates through the variables
  for (var i = 0; i < Group["VariableCount"]; i++)
  {
    var Variable = Group["Variables"](i);
    // Variable name
    var Name = Variable["Name"];
    // Variable value
    var Value = Variable["Value"];
    // Posts both the variable name and value to the test log
    Log["Message"]("The " + Name + " variable has the " + Value + " value.");
  }
}

See Also

Variables Property

Highlight search results