Count Property

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

Use the Classes.Count property to get the total number of existing classes created via the ODT project item.

Declaration

ClassesObj.Count

Read-Only Property Integer
ClassesObj An expression, variable or parameter that specifies a reference to a Classes object

Applies To

The property is applied to the following object:

Property Value

The total number of existing classes.

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

Items Property

Highlight search results