Count Property

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

Use the ArrayType.Count property to get the total number of items in the array. This value is the lower bound for the number of array items in objects that are based on the class to which ArrayType belongs.

Declaration

ArrayTypeObj.Count

Read-Only Property Integer
ArrayTypeObj An expression, variable or parameter that specifies a reference to an ArrayType 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 information about the NewProperty property of the array type and then posts the values of all of its items to the test log.

JavaScript, JScript

function GetItemValue()
{
    // Specifies the class to obtain information about
    var Obj = ODT.Classes.MyClass;
    // Specifies a property of the array type
    var Prop = Obj.NewProperty;
    // Iterates through the items
    for (var i = 0; i < Prop.Count; i++)
    {
       var PrVal = Prop.Items(i).Value;
       // Posts the current item's value to the test log
       Log.Message("Item " + i + ": " + PrVal);
    }
}

VBScript

Sub GetItemValue
    ' Specifies the class to obtain information about
    Set Obj = ODT.Classes.MyClass
    ' Specifies a property of the array type
    Set Prop = Obj.NewProperty
    ' Iterates through the items
    For i = 0 to Prop.Count-1
       PrVal = Prop.Items(i).Value
       ' Posts the current item's value to the test log
       Log.Message("Item " & i & ": " & PrVal)
    Next
End Sub

DelphiScript

function GetItemValue;
var Obj, Prop, i, PrVal;
begin
    // Specifies the class to obtain information about
    Obj := ODT.Classes.MyClass;
    // Specifies a property of the array type
    Prop := Obj.NewProperty;
    // Iterates through the items
    for i := 0 to Prop.Count-1 do
    begin
       PrVal := Prop.Items(i).Value;
       // Posts the current item's value to the test log
       Log.Message('Item ' + i + ': ' + PrVal);
    end;
end;

C++Script, C#Script

function GetItemValue()
{
    // Specifies the class to obtain information about
    var Obj = ODT["Classes"]["MyClass"];
    // Specifies a property of the array type
    var Prop = Obj["NewProperty"];
    // Iterates through the items
    for (var i = 0; i < Prop["Count"]; i++)
    {
       var PrVal = Prop["Items"](i)["Value"];
       // Posts the current item's value to the test log
       Log["Message"]("Item " + i + ": " + PrVal);
    }
}

See Also

Items Property
Count Property

Highlight search results