Updating Property Collections

Applies to TestComplete 15.63, last modified on April 23, 2024

The Objects collection of the Stores project item contains a collection of object properties that can be used in tests for comparison purposes. For example, you can compare an actual object in your application under test with a stored collection of object properties to make sure that your actual object properties have the expected values.

In some cases, you may need to update a stored collection of properties. For example, you may need to update a property collection used by an object checkpoint in order for the checkpoint to pass.

TestComplete lets you update the entire property collection either automatically from tests, or manually from the test log.

Note: If you need to modify only one or several values stored in a property collection, you can do this manually using the Objects editor or from tests. For more information on this, see Modifying Property Collections in Stores.

Updating Property Collections From Tests

Using the Update Method

To update the whole property collection, use the Update method of the Objects object. This method uses two parameters:

Objects.Update(AObject, Name)

  • Name is the name of the property collection you need to update.

  • AObject specifies the tested object (process, window, child window and so on), whose property values are used to update the values stored in the collection.

The Update method obtains the names of properties stored in the collection, retrieves the values of these properties from AObject and then replaces the stored property values with the retrieved values.

The following code demonstrates how you can use the Update method in your scripts:

JavaScript, JScript

function Update()
{
  var p;
  
  p = Sys.Process("MyProcess");
  Objects.Update(p, "Process_MyProcess");
}

Python

def Update():
  p = Sys.Process("MyProcess")
  Objects.Update(p, "Process_MyProcess")

VBScript

Sub Update
  Set p = Sys.Process("MyProcess")
  Objects.Update p, "Process_MyProcess"
End Sub

DelphiScript

procedure Update;
var
  p : OleVariant;
begin
  p := Sys.Process('MyProcess');
  Objects.Update(p, 'Process_MyProcess');
end;

C++Script, C#Script

function Update()
{
  var p;
  
  p = Sys["Process"]("MyProcess");
  Objects["Update"](p, "Process_MyProcess");
}

Using the Object Update Feature

You can update the entire property collection by using the Compare method of the Objects object, the Check method of the StoredObject object or object checkpoints. Usually, the methods and checkpoints are used to compare objects, but they can also replace a stored property collection with the collection of properties of the specified object.

In order to make it possible, enable the update feature for the desired property collection:

  • Enable the Update objects option in the Stores settings.

  • Select the Update check box of the desired property collection in the Objects editor.

With the update feature enabled, the Compare and Check methods, as well as object checkpoints, work the same way as the Update method (see above):

JavaScript, JScript

var p;
...
p = Sys.Process("MyProcess");
// Updates the whole Process_MyProcess collection
Objects.Compare (p, "Process_MyProcess");
// or
Process_MyProcess.Check (p);

Python

p = Sys.Process("MyProcess")
# Updates the whole Process_MyProcess collection
Objects.Compare (p, "Process_MyProcess")
# or
Process_MyProcess.Check (p)

VBScript

...
Set p = Sys.Process("MyProcess")
' Updates the whole Process_MyProcess collection
Objects.Compare p, "Process_MyProcess"
' or
Process_MyProcess.Check p

DelphiScript

p : OleVariant;
...
p := Sys.Process('MyProcess');
// Updates the whole Process_MyProcess collection
Objects.Compare (p, 'Process_MyProcess');
// or
Process_MyProcess.Check (p);

C++Script, C#Script

var p;
...
p = Sys["Process"]("MyProcess");
/* Updates the whole Process_MyProcess collection */
Objects["Compare"](p, "Process_MyProcess");
/* or */
Process_MyProcess["Check"](p);

To update property collections from keyword tests, use the Object Checkpoint operation or call the Objects.Compare or StoredObject.Check method by using the Call Object Method, Run Code Snippet or Run Script Routine operation.

Updating Property Collections From Test Logs

You can update property collections used by object checkpoints for comparison from the test log after the test run is over. For information on how to do this, see Updating Object Checkpoints.

See Also

About Objects Collection
About Objects Editor
Modifying Property Collections in Stores
About Object Checkpoints
Updating Object Checkpoints

Highlight search results