Classes Object

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 Classes object is intended for managing custom classes in scripts. It holds a collection of existing classes and specific methods to work with it. It also holds a method that creates new class instances.

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

To access a class in the collection, use the Items property of the Classes object. This property is a default one, that is, you can skip its name in your scripts. For instance, the following two lines are equivalent:

JavaScript, JScript

cls = ODT.Classes.Items("MyClass"); // The Items property name is used
cls = ODT.Classes("MyClass"); // The Items property name is omitted

VBScript

Set cls = ODT.Classes.Items("MyClass") ' The Items property name is used
Set cls = ODT.Classes("MyClass") ' The Items property name is omitted

DelphiScript

cls := ODT.Classes.Items('MyClass'); // The Items property name is used
cls := ODT.Classes('MyClass'); // The Items property name is omitted

C++Script, C#Script

cls = ODT["Classes"]["Items"]("MyClass"); // The Items property name is used
cls = ODT["Classes"]("MyClass"); // The Items property name is omitted

Members

Example

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

JavaScript, JScript

function ClassesItemsExample()
{
  // Obtains the total number of classes
  var ClassesNum = ODT.Classes.Count;
  
  // Iterates through the classes
  for (var i = 0; i < ClassesNum; i++)
  {
    var Name = ODT.Classes.Items(i).Name;
    // Posts the name of the current class to the test log
    Log.Message(Name);
  }
}

VBScript

Sub ClassesItemsExample()

  ' Obtains the total number of classes
  ClassesNum = ODT.Classes.Count
  
  ' Iterates through the classes
  For i = 0 to (ClassesNum - 1)
    Name = ODT.Classes.Items(i).Name
    ' Posts the name of the current class to the test log
    Log.Message(Name)
  Next

End Sub

DelphiScript

function ClassesItemsExample;
var ClassesNum, i, Name;
begin

  // Obtains the total number of classes
  ClassesNum := ODT.Classes.Count;
  
  // Iterates through the classes
  for i := 0 to (ClassesNum - 1) do
  begin
    Name := ODT.Classes.Items[i].Name;
    // Posts the name of the current class to the test log
    Log.Message(Name);
  end;

end;

C++Script, C#Script

function ClassesItemsExample()
{
  // Obtains the total number of classes
  var ClassesNum = ODT["Classes"]["Count"];
  
  // Iterates through the classes
  for (var i = 0; i < ClassesNum; i++)
  {
    var Name = ODT["Classes"]["Items"](i)["Name"];
    // Posts the name of the current class to the test log
    Log["Message"](Name);
  }
}

See Also

ODT Project Item
Class Object
Data Object

Highlight search results