Groups Property

Applies to TestComplete 15.69, last modified on November 13, 2024

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 Data.Groups property returns an existing group by group name or index in the group collection. The total number of groups is specified by the GroupCount property.

Declaration

DataObj.Groups(Index)

Read-Only Property A Group object
DataObj An expression, variable or parameter that specifies a reference to a Data 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 group in the group collection. The first group in the collection has index 0, the second - 1, etc.

Property Value

A Group object

Remarks

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

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

Example

The code below adds new variables to an existing data group.

JavaScript, JScript

function DataGroupsExample()
{
  // Specifies the group to get access to
  var Group = ODT.Data.Groups("MyGroup");
  
  // Adds new variables to the MyGroup group
  Group.AddVariable("NewVariable", 123);
  var ArrVar = Group.AddVarOfArrayType;
  ArrVar.AddItem("My text");
  ArrVar.AddItem(23);
  
  // ...
   
}

VBScript

Sub DataGroupsExample

  ' Specifies the group to get access to
  Set Group = ODT.Data.Groups("MyGroup")
  
  ' Adds new variables to the MyGroup group
  Call Group.AddVariable("NewVariable", 123)
  Set ArrVar = Group.AddVarOfArrayType
  ArrVar.AddItem("My text")
  ArrVar.AddItem(23)
  
  ' ...
   
End Sub

DelphiScript

function DataGroupsExample;
var Group, ArrVar;
begin

  // Specifies the group to get access to
  Group := ODT.Data.Groups('MyGroup');
  
  // Adds new variables to the MyGroup group
  Group.AddVariable('NewVariable', 123);
  ArrVar := Group.AddVarOfArrayType;
  ArrVar.AddItem('My text');
  ArrVar.AddItem(23);
  
  // ...
   
end;

C++Script, C#Script

function DataGroupsExample()
{
  // Specifies the group to get access to
  var Group = ODT["Data"]["Groups"]("MyGroup");
  
  // Adds new variables to the MyGroup group
  Group["AddVariable"]("NewVariable", 123);
  var ArrVar = Group["AddVarOfArrayType"];
  ArrVar["AddItem"]("My text");
  ArrVar["AddItem"](23);
  
  // ...
   
}

See Also

GroupCount Property

Highlight search results