Variables Property

Applies to TestComplete 14.10, last modified on June 5, 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

The Group.Variables property returns a variable belonging to the group by variable name or index. The total number of variables is specified by the VariableCount property.

Declaration

GroupObj.Variables(Index)

Read-Only Property Variant
GroupObj An expression, variable or parameter that specifies a reference to a Group object
Index [in]    Required    Variant    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

Index

Specifies the name or index of the variable in the group. The first group in the collection has index 0, the second - 1, etc.

Property Value

A variable that has the specified name or index.

Remarks

If the group does not contain a variable with the specified name or index, an error occurs.

Note: If you use DelphiScript, you should enclose the Index parameter in square brackets: Variables[Index].

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

VariableCount Property

Highlight search results