DeleteGroup Method

Applies to TestComplete 15.47, last modified on January 20, 2023

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 Data.DeleteGroup method to delete a group with the specified name and all the variables that belong to this group.

Declaration

DataObj.DeleteGroup(Name)

DataObj An expression, variable or parameter that specifies a reference to a Data object
Name [in]    Required    String    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Name

Specifies the name of the group to be deleted. If there is no data group with the specified name, an error occurs.

Result Value

None.

Example

The code below deletes all the groups that have no variables from the project.

JavaScript, JScript

function DeleteGroupExample()
{
  // Specifies the total number of data groups
  var GroupNum = ODT.Data.GroupCount;
  
  // Iterates through the data groups
  for (var i = 0; i < GroupNum; i++)
  {
    // Obtains the name of the current data group
    var CurGroup = ODT.Data.Groups(i);
    var Name = CurGroup.Name;
    // Checks the number of variables existing
    // in the specified group
    if (CurGroup.VariableCount == 0)
    {
      ODT.Data.DeleteGroup(Name);
      // Updates the counters
      i--;
      GroupNum--;
    }
  }
  
}

VBScript

Sub DeleteGroupExample
  
  ' Specifies the total number of data groups
  GroupNum = ODT.Data.GroupCount
  
  ' Iterates through the data groups
  For i = 0 to (GroupNum - 1)
    ' Obtains the name of the current data group
    Set CurGroup = ODT.Data.Groups(i)
    Name = CurGroup.Name
    ' Checks the number of variables existing
    ' in the specified group
    If (CurGroup.VariableCount = 0) Then
      ODT.Data.DeleteGroup(Name)
      ' Updates the counters
      i = i - 1
      GroupNum = GroupNum -1
    End If 
  Next
  
End Sub

DelphiScript

function DeleteGroupExample;
var GroupNum, i, CurGroup, Name;
begin

  // Specifies the total number of data groups
  GroupNum := ODT.Data.GroupCount;
  
  // Iterates through the data groups
  for i := 0 to (GroupNum - 1) do
  begin
    // Obtains the name of the current data group
    CurGroup := ODT.Data.Groups[i];
    Name := CurGroup.Name;
    // Checks the number of variables existing
    // in the specified group
    if (CurGroup.VariableCount = 0) then
    begin
      ODT.Data.DeleteGroup(Name);
      // Updates the counters
      Dec(i);
      Dec(GroupNum);
    end;
  end;
  
end;

C++Script, C#Script

function DeleteGroupExample()
{
  // Specifies the total number of data groups
  var GroupNum = ODT["Data"]["GroupCount"];
  
  // Iterates through the data groups
  for (var i = 0; i < GroupNum; i++)
  {
    // Obtains the name of the current data group
    var CurGroup = ODT["Data"]["Groups"](i);
    var Name = CurGroup["Name"];
    // Checks the number of variables existing
    // in the specified group
    if (CurGroup["VariableCount"] == 0)
    {
      ODT["Data"]["DeleteGroup"](Name);
      // Updates the counters
      i--;
      GroupNum--;
    }
  }
  
}

See Also

AddGroup Method
Clear Method

Highlight search results