Group Object

Applies to TestComplete 14.20, last modified on September 11, 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 objects provide a scripting interface to objects, variables and arrays that were created via the ODT project item. Each Group object is just a collection of variables of the OLEVariant type. A variable can store any OLE-compatible value: string, integer, object, array, etc. The Group object contains a number of methods and properties to manage this collection.

To access a variable in a group, use the Variables property of the Group object. This property is a default one, so, you can skip its name in your scripts. For instance:

JavaScript, JScript

var group, variable;
...
group = ODT.Data.Groups("MyGroup");
// The following two lines are equivalent
variable = group.Variables("MyVar");
variable = group("MyVar");

VBScript

Set group = ODT.Data.Groups("MyGroup")
' The following two lines are equivalent
Set var = group.Variables("MyVar")
Set var = group("MyVar")

DelphiScript

var
  group, variable : OleVariant;
begin
  ...
  group := ODT.Data.Groups('MyGroup');
  // The following two lines are equivalent
  variable := group.Variables('MyVar');
  variable := group('MyVar');
  ...
end;

C++Script, C#Script

var group, variable;
...
group = ODT["Data"]["Groups"]("MyGroup");
// The following two lines are equivalent
variable = group["Variables"]("MyVar");
variable = group("MyVar");

Members

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

Object-Driven Testing
ODT Object
ArrayType Object
Object Object

Highlight search results