ODT Object

Applies to TestComplete 15.63, last modified on April 10, 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

Use methods and properties of the ODT object to create custom objects in scripts.

With methods and properties of the ODT object, you can access other program objects used to work with custom objects and classes in scripts. The hierarchy of these objects is shown below. To read about any object listed in the hierarchy, click the object’s rectangle on the image:

Press mouse button to read about the Classes object. Press mouse button to read about the Class object. Press mouse button to read about the PropertyDeclaration object. Press mouse button to read about the Method object. Press mouse button to read about the ArrayType object. Press mouse button to read about the Data object. Press mouse button to read about the Group object. Press mouse button to read about the Object object. Press mouse button to read about the Property object. Press mouse button to read about the ArrayObject object. Press mouse button to read about the Method object.

The ODT object is available only if your project contains the ODT project item.

Members

Example

The following example obtains the Data object that provides access to data groups, posts the data groups’ names and the names of the variables stored in the groups to the test log.

JavaScript, JScript

function ODTSample()
{
  var Data, Group, Variable;
  // Obtains the Data object
  Data = ODT.Data;

  // Iterates through the data groups stored in the ODT project item
  for (var i = 0; i < Data.GroupCount; i++)
  {
    Group = Data.Groups(i);
    Log.AppendFolder(Group.Name);
    // Iterates through the variables stored in the current data group
    for (var j = 0; j < Group.VariableCount; j++)
    {
      Variable = Group.Variables(j);
      Log.Message(Variable.Name);
    }
    Log.PopLogFolder();
  }

}

VBScript

Sub ODTSample

  ' Obtains the Data object
  Set Data = ODT.Data

  ' Iterates through the data groups stored in the ODT project item
  For i = 0 To Data.GroupCount - 1
    Set Group = Data.Groups(i)
    Log.AppendFolder Group.Name
    ' Iterates through the variables stored in the current data group
    For j = 0 To Group.VariableCount - 1
      Set Variable = Group.Variables(j)
      Log.Message(Variable.Name)
    Next
    Log.PopLogFolder
  Next

End Sub

DelphiScript

procedure ODTSample();
var Data, Group, Variable, i ,j;
begin
  // Obtains the Data object
  Data := ODT.Data;

  // Iterates through the data groups stored in the ODT project item
  for i := 0 to Data.GroupCount - 1 do
  begin
    Group := Data.Groups[i];
    Log.AppendFolder(Group.Name);
    // Iterates through the variables stored in the current data group
    for j := 0 to Group.VariableCount - 1 do
    begin
      Variable := Group.Variables[j];
      Log.Message(Variable.Name);
    end;
    Log.PopLogFolder;
  end;

end;

C++Script, C#Script

function ODTSample()
{
  var Data, Group, Variable;
  // Obtains the Data object
  Data = ODT["Data"];

  // Iterates through the data groups stored in the ODT project item
  for (var i = 0; i < Data["GroupCount"]; i++)
  {
    Group = Data["Groups"](i);
    Log["AppendFolder"](Group["Name"]);
    // Iterates through the variables stored in the current data group
    for (var j = 0; j < Group["VariableCount"]; j++)
    {
      Variable = Group["Variables"](j);
      Log["Message"](Variable["Name"]);
    }
    Log["PopLogFolder"]();
  }

}

See Also

Object-Driven Testing

Highlight search results