Alternatives to Property Checkpoints

Applies to TestComplete 15.47, last modified on January 20, 2023

If in your test you need to check whether an object’s property meets a specified condition but you cannot use a property checkpoint for some reason, you can take one of the following alternative approaches:

Create a Custom Verification Procedure

In your keyword test or script, to check of an object’s property contains the desired value or verify a single property or a collection of properties, perform the following steps:

  • Obtain the desired object.
  • Obtain the value of an object’s property.
  • Compare the property value with the desired value and report the results.

To compare property values with expected values, you can use standard comparison operators, like =, <, > and so on. For example, the following script code demonstrates how to compare a property value with a baseline value:

JavaScript

function Test()
{

  …

  if (equal(Sys.Process("notepad").Window("Notepad", "*").Window("Edit", "").wText, "Test"))
    Log.Message("The property value equals the baseline value.");
  else
    Log.Error("The property value does not equal the baseline value.");
  …

}

JScript

function Test()
{

  …

  if (Sys.Process("notepad").Window("Notepad", "*").Window("Edit", "").wText == "Test")
    Log.Message("The property value equals the baseline value.");
  else
    Log.Error("The property value does not equal the baseline value.");
  …

}

Python

def Test():
  ...

  if Sys.Process("notepad").Window("Notepad", "*").Window("Edit", "").wText == "Test":
    Log.Message("The property value equals the baseline value.")
  else:
    Log.Error("The property value does not equal the baseline value.")
  ...

VBScript

Sub Test
  …

  If Sys.Process("notepad").Window("Notepad", "*").Window("Edit", "").wText = "Test" Then
    Log.Message("The property value equals the baseline value.")
  Else
    Log.Error("The property value does not equal the baseline value.")
  End If
  …

End Sub

DelphiScript

procedure Test();
begin

  …

  if Sys.Process('notepad').Window('Notepad', '*').Window('Edit', '').wText = 'Test' then
    Log.Message('The property value equals the baseline value.')
  else
    Log.Error('The property value does not equal the baseline value.');
  …

end;

C++Script, C#Script

function Test()
{

  …

  if (Sys["Process"]("notepad")["Window"]("Notepad", "*")["Window"]("Edit", "")["wText"] == "Test")
    Log["Message"]("The property value equals the baseline value.");
  else
    Log["Error"]("The property value does not equal the baseline value.");
  …

}

Use Operations and Methods for Property Comparison

In keyword tests, to check a property value against the specified baseline value and report the results, you can also use the Compare Properties operation. This operation allows you to specify what kind of message (an error, warning, informative message, or no message at all) will be posted to the test log if the comparison fails.

In scripts, the aqObject.CompareProperty method also allows verifying property values. The code below demonstrates how to use the method to verify an object’s property:

JavaScript, JScript

function ComparePropertySample()
{

  var prop = Sys.Process("notepad").Window("Notepad", "*").Window("Edit", "").wText;
  var value = "test";

  // Compares the property value with the specified baseline value
  // And posts an error if the comparison fails
  aqObject.CompareProperty(prop, cmpEqual, value, true, lmError);
}

Python

def ComparePropertySample():
  prop = Sys.Process("notepad").Window("Notepad", "*").Window("Edit", "").wText
  value = "test"

  # Compares the property value with the specified baseline value
  # And posts an error if the comparison fails
  aqObject.CompareProperty(prop, cmpEqual, value, True, lmError)

VBScript

Sub ComparePropertySample()

  prop = Sys.Process("notepad").Window("Notepad", "*").Window("Edit", "").wText
  value = "test"

  ' Compares the property value with the specified baseline value
  ' And posts an error if the comparison fails
  Call aqObject.CompareProperty(prop, cmpEqual, value, true, lmError)

End Sub

DelphiScript

procedure ComparePropertySample();
var prop, value : string;
begin

  prop := Sys.Process('notepad').Window('Notepad', '*').Window('Edit', '').wText;
  value := 'test';

  // Compares the property value with the specified baseline value
  // And posts an error if the comparison fails
  aqObject.CompareProperty(prop, cmpEqual, value, true, lmError);
end;

C++Script, C#Script

function ComparePropertySample()
{

  var prop = Sys["Process"]("notepad")["Window"]("Notepad", "*")["Window"]("Edit", "")["wText"];
  var value = "test";

  // Compares the property value with the specified baseline value
  // And posts an error if the comparison fails
  aqObject["CompareProperty"](prop, cmpEqual, value, true, lmError);
}

See Also

Property Checkpoints
About Property Checkpoints
About Object Checkpoints

Highlight search results