Properties 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

The Class.Properties property returns the PropertyDeclaration object that represents a class property. The total number of properties is specified by the PropertyCount property.

Declaration

ClassObj.Properties(Index)

Read-Only Property A PropertyDeclaration object
ClassObj An expression, variable or parameter that specifies a reference to a Class object
Index [in]    Required    Variant    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

Index

The Index parameter specifies either the property name, or index. The first property has index 0, the second - 1, and so on.

Property Value

A PropertyDeclaration object.

Remarks

If a class or an object does not contain the property with the specified name or index, an error occurs.

Note: If you use DelphiScript, you should enclose the Index parameter in square brackets: Properties[Index].

Example

The code below posts the names and values of all the properties that belong to the MyClass class to the test log.

JavaScript, JScript

function PropertiesExample()
{
  // Specifies the class name
  var MyClass = ODT.Classes.MyClass;
  // Obtains the total number of the class's properties
  var PropNum = MyClass.PropertyCount;
  
  // Iterates through the properties
  for (var i = 0; i < PropNum; i++)
  {
    var PropName = MyClass.Properties(i).Name;
    var PropValue = MyClass.Properties(i).Value;
    // Posts a property's name and value to the test log
    Log.Message("The " + PropName + " property has the " + PropValue + " value.");
  }
}

VBScript

Sub PropertiesExample()

  ' Specifies the class name
  Set MyClass = ODT.Classes.MyClass
  ' Obtains the total number of the class's properties
  PropNum = MyClass.PropertyCount
  
  ' Iterates through the properties
  For i = 0 to (PropNum - 1)
    PropName = MyClass.Properties(i).Name
    PropValue = MyClass.Properties(i).Value
    ' Posts a property's name and value to the test log
    Log.Message("The " & PropName & " property has the " & PropValue & " value.")
  Next

End Sub

DelphiScript

function PropertiesExample;
var MyClass, PropNum, i, PropName, PropValue;
begin

  // Specifies the class name
  MyClass := ODT.Classes.MyClass;
  // Obtains the total number of the class's properties
  PropNum := MyClass.PropertyCount;
  
  // Iterates through the properties
  for i := 0 to (PropNum - 1) do
  begin
    PropName := MyClass.Properties[i].Name;
    PropValue := MyClass.Properties[i].Value;
    // Posts a property's name and value to the test log
    Log.Message('The ' + PropName + ' property has the ' + PropValue + ' value.');
  end;

end;

C++Script, C#Script

function PropertiesExample()
{
  // Specifies the class name
  var MyClass = ODT["Classes"]["MyClass"];
  // Obtains the total number of the class's properties
  var PropNum = MyClass["PropertyCount"];
  
  // Iterates through the properties
  for (var i = 0; i < PropNum; i++)
  {
    var PropName = MyClass["Properties"](i)["Name"];
    var PropValue = MyClass["Properties"](i)["Value"];
    // Posts a property's name and value to the test log
    Log["Message"]( "The " + PropName + " property has the " + PropValue + " value." );
  }
}

See Also

PropertyDeclaration Object
Properties Property
PropertyCount Property
Methods Property

Highlight search results