Data Object

Applies to TestComplete 14.92, last modified on September 16, 2021

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 object is intended for managing objects and variables created via the ODT project item. It holds a collection of existing data groups and specific methods to work with it. It also contains methods used to create and delete data groups.

You can obtain the Data object in scripts by using the Data property of the ODT object.

To access a data group from scripts, use the Groups property of the Data object. This property is a default one, so, you can skip its name in scripts. For instance, the two following lines are equivalent:

JavaScript, JScript

group = ODT.Data.Groups("MyGroup"); //The Groups property name is used
group = ODT.Data("MyGroup"); //The Groups property name is omitted

VBScript

Set group = ODT.Data.Groups("MyGroup") 'The Groups property name is used
Set group = ODT.Data("MyGroup") 'The Groups property name is omitted

DelphiScript

group := ODT.Data.Groups('MyGroup'); //The Groups property name is used
group := ODT.Data('MyGroup'); //The Groups property name is omitted

C++Script, C#Script

group = ODT["Data"]["Groups"]("MyGroup"); //The Groups property name is used
group = ODT["Data"]("MyGroup"); //The Groups property name is omitted

Members

Example

The code below obtains the names of all the data groups existing in the current project and then posts these names to the test log.

JavaScript, JScript

function DataGroupCountExample()
{
  // Obtains the total number of groups
  var GroupNum = ODT.Data.GroupCount;
  
  // Iterates through the data groups
  for (var i = 0; i < GroupNum; i++)
  {
    var GrName = ODT.Data.Groups(i).Name;
    // Posts the name of the current group to the test log
    Log.Message(GrName);
  }
     
}

VBScript

Sub DataGroupCountExample

  ' Obtains the total number of groups
  GroupNum = ODT.Data.GroupCount
  
  ' Iterates through the data groups
  For i = 0 to (GroupNum - 1)
    GrName = ODT.Data.Groups(i).Name
    ' Posts the name of the current group to the test log
    Log.Message(GrName)
  Next 
     
End Sub

DelphiScript

function DataGroupCountExample;
var GroupNum, i, GrName;
begin

  // Obtains the total number of groups
  GroupNum := ODT.Data.GroupCount;
  
  // Iterates through the data groups
  for i := 0 to (GroupNum - 1) do
  begin
    GrName := ODT.Data.Groups[i].Name;
    // Posts the name of the current group to the test log
    Log.Message(GrName);
  end;
     
end;

C++Script, C#Script

function DataGroupCountExample()
{
  // Obtains the total number of groups
  var GroupNum = ODT["Data"]["GroupCount"];
  
  // Iterates through the data groups
  for (var i = 0; i < GroupNum; i++)
  {
    var GrName = ODT.Data["Groups"](i)["Name"];
    // Posts the name of the current group to the test log
    Log["Message"](GrName);
  }
     
}

See Also

ODT Object
Object-Driven Testing
Classes Object
Group Object

Highlight search results