StoredObject Object

Applies to TestComplete 14.72, last modified on April 22, 2021

Description

The StoredObject object provides a scripting interface to individual property collections that are elements of the Objects collection of the Stores project item. To obtain the object in scripts, use the StoredObject property of the Objects object. Once you have obtained scripting access to a collection, you can enumerate properties included in the collection, obtain property names, change values and so on.

Note that a property collection can hold both properties of parent and child objects (for example, properties of a parent window and its child windows). The collections store property values in a tree-like structure: parent window’s properties are stored in the collection itself, child window properties are stored in child collections. You can see the child collections in the middle section of the Objects editor. TestComplete uses the StoredObject objects to represent both parent and child property collections.

Requirements

The StoredObject object is available only if your project contains the Stores project item with the Objects collection in it.

Members

Example

The following code demonstrates how you can access the desired item of the Objects collection and the properties stored in this item.

JavaScript, JScript

function Test1()
{
  // Obtains the specified property collection
  StoredObject = Objects.Items("MyCollection");
  Log.Message("The total number of property values stored by the collection: " + StoredObject.PropertyCount);

  // Access the specified stored property
  StoredObjectProperty = StoredObject.Properties(0);
    // --or--
  // StoredObjectProperty = StoredObject.PropertyByName("Caption");
  PropertyName = StoredObjectProperty.Name;
  PropertyValue = StoredObjectProperty.Value;
  Log.Message(PropertyName + " = " + PropertyValue);
}

Python

def Test1():
  # Obtains the specified property collection 
  StoredObject = Objects.Items("MyCollection")
  Log.Message("The total number of property values stored by the collection: " + str(StoredObject.PropertyCount))
  # Access the specified stored property  
  StoredObjectProperty = StoredObject.Properties[0]
  # --or-- 
  # StoredObjectProperty = StoredObject.PropertyByName["Caption"]
  PropertyName = StoredObjectProperty.Name 
  PropertyValue = StoredObjectProperty.Value
  Log.Message(PropertyName + " = " + str(PropertyValue))

VBScript

Sub Test1
  ' Obtains the specified property collection
  Set StoredObject = Objects.Items("MyCollection")
  Log.Message("The total number of property values stored by the collection: " & StoredObject.PropertyCount)

  ' Access the specified stored property
  Set StoredObjectProperty = StoredObject.Properties(0)
    ' --or--
  ' Set StoredObjectProperty = StoredObject.PropertyByName("Caption")
  PropertyName = StoredObjectProperty.Name
  PropertyValue = StoredObjectProperty.Value
  Log.Message(PropertyName & " = " & PropertyValue)
End Sub

DelphiScript

procedure Test1;
begin
  // Obtains the specified property collection
  StoredObject := Objects.Items('MyCollection');
  Log.Message('The total number of property values stored by the collection: ' + StoredObject.PropertyCount);

  // Access the specified stored property
  StoredObjectProperty := StoredObject.Properties(0);
    // --or--
  // StoredObjectProperty := StoredObject.PropertyByName('Caption');
  PropertyName := StoredObjectProperty.Name;
  PropertyValue := StoredObjectProperty.Value;
  Log.Message(PropertyName + ' = ' + PropertyValue);
end;

C++Script, C#Script

function Test1()
{
  // Obtains the specified property collection
  StoredObject = Objects["Items"]("MyCollection");
  Log["Message"]("The total number of property values stored by the collection: " + StoredObject["PropertyCount"]);

  // Access the specified stored property
  StoredObjectProperty = StoredObject["Properties"](0);
    // --or--
  // StoredObjectProperty = StoredObject["PropertyByName"]("Caption");
  PropertyName = StoredObjectProperty["Name"];
  PropertyValue = StoredObjectProperty["Value"];
  Log["Message"](PropertyName + " = " + PropertyValue);
}

See Also

StoredObjectProperty Object
Modifying Property Collections in Stores
Stores

Highlight search results