Count Property

Applies to TestComplete 15.70, last modified on December 17, 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 the ArrayObject.Count property to get the total number of items in ArrayObject. This number can differ from the number of array items in the ArrayType object on which ArrayObject is based, because you can add items to the array upon creating the object that will contain this array.

Declaration

ArrayObjectObj.Count

Read-Only Property Integer
ArrayObjectObj An expression, variable or parameter that specifies a reference to an ArrayObject object

Applies To

The property is applied to the following object:

Property Value

The total number of items in the array.

Example

The code below obtains a collection of items that belong to the MyProperty property of the array type and then posts the items' values to the test log.

JavaScript, JScript

function ArrayItems()
{
   // Specifies the property to obtain information about
   var Prop = ODT.Classes.TestClass.MyProperty;
   // Obtains the total number of items that belong to the MyProperty array
   var iNum = Prop.Count;
   for (var i = 0; i < iNum; i++)
   {
     // Obtains the current item's value
     var iVal = Prop.Items(i).Value;
     Log.Message("The " + i + " item's value is: " + iVal);
   }
}

VBScript

Sub ArrayItems
   ' Specifies the property to obtain information about
   Set Prop = ODT.Classes.TestClass.MyProperty
   ' Obtains the total number of items that belong to the MyProperty array
   iNum = Prop.Count
   For i = 0 to iNum-1
     ' Obtains the current item's value
     iVal = Prop.Items(i).Value
     Log.Message("The " & i & " item's value is: " & iVal)
   Next
End Sub

DelphiScript

function ArrayItems;
var Prop, iNum, i, iVal;
begin
   // Specifies the property to obtain information about
   Prop := ODT.Classes.TestClass.MyProperty;
   // Obtains the total number of items that belong to the MyProperty array
   iNum := Prop.Count;
   for i := 0 to iNum-1 do
   begin
     // Obtains the current item's value
     iVal := Prop.Items(i).Value;
     Log.Message('The ' + i + ' item''s value is: ' + iVal);
   end;
end;

C++Script, C#Script

function ArrayItems()
{
   // Specifies the property to obtain information about
   var Prop = ODT["Classes"]["TestClass"]["MyProperty"];
   // Obtains the total number of items that belong to the MyProperty array
   var iNum = Prop["Count"];
   for (var i = 0; i < iNum; i++)
   {
     // Obtains the current item's value
     var iVal = Prop["Items"](i)["Value"];
     Log["Message"]("The " + i + " item's value is: " + iVal);
   }
}

See Also

Items Property
Count Property

Highlight search results