Adding Property Collections to Stores

Applies to TestComplete 14.10, last modified on June 5, 2019

You can add collections of object properties to Stores in several ways (see below). TestComplete stores the object properties to a hard disk. The stored properties are also displayed in the Objects editor, where you can view and modify them.

Note: A note before you proceed. It concerns storing object properties through the Store Object Properties dialog (as you will see below, this dialog is used in most of the described approaches):

When storing object properties that reside in an Open Application, remember that some object properties may be unavailable to TestComplete and, thus, their values are not displayed in the Store Object Properties dialog and cannot be stored. See Object Properties, Fields and Methods That Are Unavailable to TestComplete.

Besides, TestComplete cannot store indexed properties, that is, those properties that require one or more additional parameters to get a value. These properties are not displayed in the Store Object Properties dialog either.

Also, note that, by default, protected and private properties are hidden from the dialog. If you want to store their values, enable the Show hidden members option in the Engines - General Options dialog. See Access to Properties for more information.

Adding Property Collections From the Project Explorer

To add a property collection from the Project Explorer:

  1. Switch to the Project Explorer panel (if it is hidden, select View | Project Explorer from the TestComplete main menu to make the panel visible).

  2. Right-click the Stores | Objects node in the Project Explorer panel and select Add | New Item from the context menu.

  3. Use the subsequent Add Object wizard to specify the object and its properties to store, or to import an existing file containing stored object data to your project.

Adding Property Collections From the Objects Editor

  1. Open the Objects editor.

  2. Right-click somewhere within the editor and choose New Item from the context menu.

  3. In the ensuing Add Object wizard, you specify the object you want to store and its properties or select an existing file containing object data you want to add to your project.

For more information on how to do this, see About Objects Editor.

Adding Property Collections From the Object Browser

  1. Switch to the Object Browser panel (if it is hidden, select View | Object Browser from the context menu to make the panel visible).

  2. Find the desired object in the Object tree. Right-click this object and select Store Object from the context menu.

  3. (Optional) If your project suite contains several projects, TestComplete will show the Select Project dialog asking you to select the project to which you will add the collection of property values.

  4. If the selected object has child objects, TestComplete asks whether you want to store the properties of child object’s.

  5. Then TestComplete will show the Store Object Properties dialog, where you can define which property values are to be included in the collection and saved to Stores.

Adding Property Collections From the Object Spy Window

For more information on this, see Storing Object Properties From Object Browser.

Adding Property Collections From Tests

To add a property collection to Stores from tests, call the Objects.Save method within your keyword test or script. This method combines property names and values into a collection and saves it to the Object list of the Stores project item. The following code demonstrates the use of this method:

JavaScript, JScript

var w, PropertyNames, CollectionName;
w = Sys.Desktop.ActiveWindow();
// Prepares the property list
PropertyNames = "Top Left Height Width";
// Sets the name of the property collection
CollectionName = "ActiveWindowProps";
// Saves values of properties specified in PropertyNames.
// Note that the Save method also has the fourth parameter
// that lets you not to save certain properties.
Objects.Save(w, CollectionName, PropertyNames);

Python

w = Sys.Desktop.ActiveWindow()
# Prepares the property list
PropertyNames = "Top Left Height Width"
# Sets the name of the property collection
CollectionName = "ActiveWindowProps"
# Saves values of properties specified in PropertyNames.
# Note that the Save method also has the fourth parameter
# that lets you not to save certain properties.
Objects.Save(w, CollectionName, PropertyNames)

VBScript

Set w = Sys.Desktop.ActiveWindow
' Prepares the property list
PropertyNames = "Top Left Height Width"
' Sets the name of a property collection
CollectionName = "ActiveWindowProps"
 
' Saves values of properties specified in PropertyNames.
' Note that the Save method also has the fourth parameter
' that lets you not to save certain properties.
Objects.Save w, CollectionName, PropertyNames

DelphiScript

var
  w, PropertyNames, CollectionName : OleVariant;
begin
  w := Sys.Desktop.ActiveWindow();
  // Prepares the property list
  PropertyNames := 'Top Left Height Width';
  // Sets the name of the property collection
  CollectionName := 'ActiveWindowProps';
  // Saves values of properties specified in PropertyNames.
  // Note that the Save method also has the fourth parameter
  // that lets you not to save certain properties.
  Objects.Save(w, CollectionName, PropertyNames);

C++Script, C#Script

var w, PropertyNames, CollectionName;
w = Sys["Desktop"]["ActiveWindow"]();
// Prepares the property list
PropertyNames = "Top Left Height Width";
// Sets the name of the property collection
CollectionName = "ActiveWindowProps";
// Saves values of properties specified in PropertyNames.
// Note that the Save method also has the fourth parameter
// that lets you not to save certain properties.
Objects["Save"](w, CollectionName, PropertyNames);

Note: If the Objects collection already contains a property collection with the specified name, the Save method will overwrite the property collection file without any warning.

To call the Objects.Save method from your keyword test, use the Call Object Method or Run Code Snippet operation.

See Also

About Objects Collection
About Objects Editor
Objects Object
About Object Checkpoints

Highlight search results