ArrayItem Object

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 ArrayItem object provides a scripting interface to elements of arrays created via the ODT project item. It is used to work with items of both ArrayObject and ArrayType arrays.

An array item can store any OLEVariant value. It can hold a string, an integer, a reference to an object or be an array itself.

Members

Example

The code below demonstrates how you can access the names and values of the specified array's items. The routine obtains the collection of properties that belong to the MyClass class and posts the properties' names and values to the test log.

JavaScript, JScript

function ArrayItem()
{
   // Obtains information about the MyClass class
   var PrCol = ODT.Classes.MyClass;
   for (var i = 0; i < PrCol.PropertyCount; i++)
   {
     // Obtains the current property's name
     var PrName = PrCol.Properties(i).Name;
     var PrValue = PrCol.Properties(i).Value;
     // Posts the property's name and value to the test log
     Log.Message(PrName + " property equals to " + PrValue);
   }
}

VBScript

Sub ArrayItem
   ' Obtains information about the MyClass class
   Set PrCol = ODT.Classes.MyClass
   For i = 0 to PrCol.PropertyCount-1
     ' Obtains the current property's name
     PrName = PrCol.Properties(i).Name
     PrValue = PrCol.Properties(i).Value
     ' Posts the property's name and value to the test log
     Log.Message(PrName & " property equals to " & PrValue)
   Next
End Sub

DelphiScript

function ArrayItem;
var PrCol, i, PrName, PrValue;
begin
   // Obtains information about the MyClass class
   PrCol := ODT.Classes.MyClass;
   For i := 0 to PrCol.PropertyCount-1 Do
   begin
     // Obtains the current property's name
     PrName := PrCol.Properties(i).Name;
     PrValue := PrCol.Properties(i).Value;
     // Posts the property's name and value to the test log
     Log.Message(PrName + ' property equals to ' + PrValue);
   end;
end;

C++Script, C#Script

function ArrayItem()
{
   // Obtains information about the MyClass class
   var PrCol = ODT["Classes"]["MyClass"];
   for (var i = 0; i < PrCol["PropertyCount"]; i++)
   {
     // Obtains the current property's name
     var PrName = PrCol["Properties"](i)["Name"];
     var PrValue = PrCol["Properties"](i)["Value"];
     // Posts the property's name and value to the test log
     Log["Message"](PrName + " property equals to " + PrValue);
   }
}

See Also

ArrayObject Object
ArrayType Object

Highlight search results