Properties Property

Applies to TestComplete 14.0, last modified on January 23, 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

The Object.Properties property returns the Property object that represents an object property. The total number of properties is specified by the PropertyCount property.

Declaration

ObjectObj.Properties(Index)

Read-Only Property A Property object
ObjectObj An expression, variable or parameter that specifies a reference to an Object object
Index [in]    Required    Variant    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

Index

Specifies either the property name, or index. The first property has index 0, the second - 1, etc.

Property Value

A Property object

Remarks

If the class or object does not contain a 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 following code snippet declares a new class, adds several properties to it and creates an object based on the declared class. After that, it adds another property to the object and iterates through the object’s properties posting information on them to the test log.

JavaScript, JScript

function ObjectSample()
{

ODT.Data.Clear();
ODT.Classes.Clear();
  var NewClass, MyObject, Prop;
  // Declares a new class
  NewClass = ODT.Classes.Declare("NewClass")
  // Adds properties to the declared class
  NewClass.AddProperty("ClassProperty1", "Value1");
  NewClass.AddProperty("ClassProperty2", "Value2");

  // Creates an object based on the declared class
  MyObject = ODT.Classes.New("NewClass");
  // Adds a property to the object
  MyObject.AddProperty("ObjectProperty", "Value3");

  // Iterates through the object’s properties
  for (var i = 0; i < MyObject.PropertyCount; i++)
  {
    // Obtains the object’s property by its index
    Prop = MyObject.Properties(i);

    // Posts information on the property to the test log
    Log.AppendFolder(Prop.Name);
    Log.Message("Enabled: " + Prop.Enabled);
    Log.PopLogFolder();
  }

}

VBScript

Sub ObjectSample

ODT.Data.Clear
ODT.Classes.Clear
  ' Declares a new class
  Set NewClass = ODT.Classes.Declare("NewClass")
  ' Adds properties to the declared class
  Call NewClass.AddProperty("ClassProperty1", "Value1")
  Call NewClass.AddProperty("ClassProperty2", "Value2")

  ' Creates an object based on the declared class
  Set MyObject = ODT.Classes.New("NewClass")
  ' Adds a property to the object
  Call MyObject.AddProperty("ObjectProperty", "Value3")

  ' Iterates through the object’s properties
  For i = 0 To MyObject.PropertyCount - 1
    ' Obtains the object’s property by its index
    Set Prop = MyObject.Properties(i)

    ' Posts information on the property to the test log
    Log.AppendFolder Prop.Name
    Log.Message "Enabled: " & Prop.Enabled
    Log.PopLogFolder
  Next

End Sub

DelphiScript

procedure ObjectSample();

var NewClass, MyObject, i, Prop;
begin
ODT.Data.Clear;
ODT.Classes.Clear;
  // Declares a new class
  NewClass := ODT.Classes.Declare('NewClass');
  // Adds properties to the declared class
  NewClass.AddProperty('ClassProperty1', 'Value1');
  NewClass.AddProperty('ClassProperty2', 'Value2');

  // Creates an object based on the declared class
  MyObject := ODT.Classes.New('NewClass');
  // Adds a property to the object
  MyObject.AddProperty('ObjectProperty', 'Value3');

  // Iterates through the object’s properties
  for i := 0 to MyObject.PropertyCount - 1 do
  begin
    // Obtains the object’s property by its index
    Prop := MyObject.Properties[i];

    // Posts information on the property to the test log
    Log.AppendFolder(Prop.Name);
    Log.Message('Enabled: ' + aqConvert.VarToStr(Prop.Enabled));
    Log.PopLogFolder();
  end;

end;

C++Script, C#Script

function ObjectSample()
{

ODT["Data"]["Clear"]();
ODT["Classes"]["Clear"]();
  var NewClass, MyObject, Prop;
  // Declares a new class
  NewClass = ODT["Classes"]["Declare"]("NewClass")
  // Adds properties to the declared class
  NewClass["AddProperty"]("ClassProperty1", "Value1");
  NewClass["AddProperty"]("ClassProperty2", "Value2");

  // Creates an object based on the declared class
  MyObject = ODT["Classes"]["New"]("NewClass");
  // Adds a property to the object
  MyObject["AddProperty"]("ObjectProperty", "Value3");

  // Iterates through the object’s properties
  for (var i = 0; i < MyObject["PropertyCount"]; i++)
  {
    // Obtains the object’s property by its index
    Prop = MyObject["Properties"](i);

    // Posts information on the property to the test log
    Log["AppendFolder"](Prop["Name"]);
    Log["Message"]("Enabled: " + Prop["Enabled"]);
    Log["PopLogFolder"]();
  }

}

See Also

Property Object
PropertyCount Property
Methods Property

Highlight search results