Modifying Property Collections in Stores

Applies to TestComplete 14.92, last modified on September 16, 2021

The Objects collection of the Stores project item contains a collection of object properties that can be used in tests for comparison purposes.

In some cases, you may need to modify the properties stored in a property collection (for example, to modify one or several properties stored in the collection). You can do this manually in the Objects editor or automatically, from tests.

Note: If you need to update the entire collection of object properties, see Updating Property Collections.

Modifying Property Values in the Objects Editor

To edit property values of a property collection in the Objects editor, do the following:

  • Select the desired property collection in the Objects editor’s list.

  • The Preview section will display the property collection’s contents.

  • Click Edit in the Preview section.

  • Use the resulting Edit Objects dialog to edit the property values.

  • Click OK to close the dialog and save the changes. The property collection will be updated.

Modifying Property Values From Tests

To access individual property collections added to the Objects collection in tests, use the StoredObject or Items method of the Objects object. The StoredObject object they return provides a scripting interface to a property collection and allows obtaining and changing property values.

The following code demonstrates how to obtain a property collection by using the StoredObject method of the Objects object.

JavaScript, JScript


// Obtains the desired property collection
var processNotepad = Objects.StoredObject("processNotepad");

Python

...
# Obtains the desired property collection
processNotepad = Objects.StoredObject("processNotepad")
...

VBScript


' Obtains the desired property collection
Set processNotepad = Objects.StoredObject("processNotepad")

DelphiScript

processNotepad : OleVariant;

// Obtains the desired property collection
processNotepad := Objects.StoredObject('processNotepad');

C++Script, C#Script


// Obtains the desired property collection
var processNotepad = Objects["StoredObject"]("processNotepad");

Note that a property collection can hold the properties of parent and child objects (for example, the properties of a parent window and the properties of child windows). A collection stores property values in a tree-like structure. You can see the hierarchy in the Preview section of the Objects editor.

The StoredObject object lets you work with properties stored in a given property collection and obtain access to child collections.

The following code demonstrates how you can update a single property in a property collection added to Stores. The example assumes that the collection contains properties of the Notepad process object and of its child objects.

JavaScript, JScript

function Test()
{
  var Collection, ChildCollection, MyProperty;
  
  // Obtains the desired property collection
  Collection = Objects.StoredObject("Process_Notepad");
  // Obtains the desired child collection
  ChildCollection = Collection.ChildByName("Window(\"Notepad\", \"Untitled - Notepad\", 1)");
  ChildCollection = ChildCollection.ChildByName("Window(\"Edit\", \"\", 1)");
  // Updates the property value
  MyProperty = ChildCollection.PropertyByName("wText");
  MyProperty.Value = "New value";
}

Python

def Test():
  # Obtains the desired property collection
  Collection = Objects.StoredObject("Process_Notepad")
  # Obtains the desired child collection
  ChildCollection = Collection.ChildByName["Window(\"Notepad\", \"Untitled - Notepad\", 1)"]
  ChildCollection = ChildCollection.ChildByName["Window(\"Edit\", \"\", 1)"]
  # Updates the property value
  MyProperty = ChildCollection.PropertyByName["wText"]
  MyProperty.Value = "New value"

VBScript

Sub Test
  Dim Collection, ChildCollection, MyProperty   
  ' Obtains the desired property collection
  Set Collection = Objects.StoredObject("Process_Notepad")
  ' Obtains the desired child collection
  Set ChildCollection = Collection.ChildByName("Window(" + Chr(34) + "Notepad" + Chr(34) + ", " + _
                                            Chr(34) + "Untitled - Notepad" + Chr(34) + ", 1)")
  Set ChildCollection = ChildCollection.ChildByName("Window(" + Chr(34) + "Edit" + Chr(34) + ", " + _
                                            Chr(34) + Chr(34) + ", 1)")
  ' Updates the property value
  Set MyProperty = ChildCollection.PropertyByName("wText")
  MyProperty.Value = "New value"
End Sub

DelphiScript

procedure Test;
var
  Collection, ChildCollection, MyProperty;
begin
  // Obtains the desired property collection
  Collection := Objects.StoredObject['Process_Notepad'];
  // Obtains the desired child collection
  ChildCollection := Collection.ChildByName['Window(''Notepad'', ''Untitled - Notepad'', 1)'];
  ChildCollection := ChildCollection.ChildByName['Window(''Edit'', '''', 1)'];
  // Updates the property value
  MyProperty := ChildCollection.PropertyByName['wText'];
  MyProperty.Value := 'New value';
end;

C++Script, C#Script

function Test()
{
  var Collection, ChildCollection, MyProperty;
  
  // Obtains the desired property collection
  Collection = Objects["StoredObject"]("Process_Notepad");
  // Obtains the desired child collection
  ChildCollection = Collection["ChildByName"]("Window(\"Notepad\", \"Untitled - Notepad\", 1)");
  ChildCollection = ChildCollection["ChildByName"]("Window(\"Edit\", \"\", 1)");
  // Updates the property value
  MyProperty = ChildCollection["PropertyByName"]("wText");
  MyProperty["Value"] = "New value";
}

See Also

About Objects Collection
Updating Property Collections
About Objects Editor

Highlight search results