Items Property

Applies to TestComplete 15.45, last modified on December 01, 2022

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.Items property returns an existing class as a Class object. The total number of classes is specified by the Count property.

Declaration

ClassesObj.Items(Index)

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

Property Value

A Class object.

Remarks

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

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

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

Count Property

Highlight search results