Name Property

Applies to TestComplete 15.44, last modified on November 10, 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

Specifies the name of the array item. You can use this name to address the array item. The item name is read-only. It differs from the item index only by the data type (the name is a string while the index is an integer). The name of the first array in the item is “0”, the name of the second item - “1”, etc.

Declaration

ArrayItemObj.Name

Read-Only Property String
ArrayItemObj An expression, variable or parameter that specifies a reference to an ArrayItem object

Applies To

The property is applied to the following object:

Property Value

The name of the array item.

Example

The code below 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

Index Property (ArrayItem Objects)

Highlight search results