PropertyCount Property

Applies to TestComplete 14.30, last modified on November 21, 2019

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 Class.PropertyCount property to get the total number of properties in the specified class.

Declaration

ClassObj.PropertyCount

Read-Only Property Integer
ClassObj An expression, variable or parameter that specifies a reference to a Class object

Applies To

The property is applied to the following object:

Property Value

The total number of properties in the class.

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 PropertyCountExample()
{
  // 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 PropertyCountExample()

  ' 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 PropertyCountExample;
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 PropertyCountExample()
{
  // 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

MethodCount Property
Methods Property
Properties Property
PropertyCount Property

Highlight search results