aqObject.CheckProperty Method

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

Description

The aqObject.CheckProperty method allows you to perform a property checkpoint from script code, that is, to verify an object’s property value according to a certain condition. If the verification succeeds, the method posts a success message to the test log; otherwise it posts a failure message.

The method can test properties that have simple value types (string, number, boolean and so on) and does not support properties that contain complex values such as arrays, objects and alike. If test properties have different value types, TestComplete will try to convert the object property value to the type of the expected value and then perform verification.

Note: If an object has a property or method that returns a DISPID_VALUE (for information on this, see DISPID Constants in the MSDN Library), the object is considered to have a value of a simple type and can be used for property validation. For example, a JavaScript array of simple values is an object with a string value (comma-separated list of items) and a .NET string is an object with a property returning the string contents.

Note that instead of using the aqObject.CheckProperty method, you can compare property values with expected values using the appropriate scripting language operators: =, >, >=, <, <= and so on. Using the aqObject.CheckProperty method makes sense if you need to perform complex string comparisons like "contains", "starts with" and so on, with or without letter case taken into account.

Declaration

aqObject.CheckProperty(Object, Property, Condition, Value, CaseSensitive)

Object [in]    Required    Variant    
Property [in]    Required    String    
Condition [in]    Required    Integer    
Value [in]    Required    Variant    
CaseSensitive [in]    Optional    Boolean Default value: True   
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Object

The object whose property you want to check.

Property

The name of the property to be checked.

If the property with the given name is not found, an error occurs. Use the aqObject.IsSupported method to verify whether the object has a certain property.

Condition

One of the following constants that specifies the property value test condition:

Constant Value Description
cmpEqual 0 Check whether the Property value equals Value.
cmpNotEqual 1 Check whether the Property value is not equal to Value.
cmpGreater 2 Check whether the Property value is greater than Value.
cmpLess 3 Check whether the Property value is less than Value.
cmpGreaterOrEqual 4 Check whether the Property value is greater or equal to Value.
cmpLessOrEqual 5 Check whether the Property value is less or equal to Value.
cmpContains 6 Check whether the Property value contains Value.
cmpNotContains 7 Check if the Property value does not contain Value.
cmpStartsWith 8 Check whether the Property value starts with Value.
cmpNotStartsWith 9 Check if the Property value does not start with Value.
cmpEndsWith 10 Check whether the Property value ends with Value.
cmpNotEndsWith 11 Check if the Property value does not end with Value.
cmpMatches 12 Check whether the Property value matches the regular expression specified by Value.
cmpNotMatches 13 Check if the Property value does not match the regular expression specified by Value.
cmpIn 14 Check if Value contains the Property value. (Similar to cmpContains, but the other way round.)
cmpNotIn 15 Check if Value does not contain the Property value. (Similar to cmpNotContains, but the other way round.)

When testing a property value of a string type, you can use any of these conditions. For more information about string comparison rules, see the Remarks section.

When testing a numeric property value, you can use any of the following conditions: cmpEqual, cmpNotEqual, cmpGreater, cmpLess, cmpGreaterOrEqual, cmpLessOrEqual.

When testing a property that has a boolean value, you can only use the cmpEqual or cmpNotEqual condition.

Value

Specifies the value to test the property value against. The meaning of this parameter depends on the Condition parameter (see the table above).

CaseSensitive

If Value is string, this parameter specifies whether the method should perform case-sensitive or case-insensitive comparison; otherwise, this parameter is ignored. By default, this parameter is True, which means case-sensitive comparison; False means that the letter case is ignored.

Result Value

True if the property value matches the specified condition and False otherwise.

Remarks

  • By default, if the Check method cannot access the object whose property it should verify, or the property does not match its baseline value, the method will wait for the object to become accessible and for the property to pass the verification for the period the Auto-wait timeout setting specifies. (Go to Tools > Current Project Properties > Playback to view or modify the setting.) If the method fails to access the object, or if object property value does not match the expected value within this period, the comparison will fail.

  • String comparisons ("equals to", "greater than", "less than" and similar) use character codes and are not affected by the locale. For example, "b" is greater than "a", "c" is greater than "b" and so on. If the CaseSensitive parameter is True, letter case is taken into account ("a" is greater than "A"), otherwise it is ignored ("a" is equal to "A"). The comparison is performed symbol-by-symbol and finishes once a difference is found or when both strings have been compared to the end. If two strings having different lengths compare as equal to the end of one string, the longer string is considered as the greater one. For instance, "abcd" is greater than "ab".

  • You can use the cmpIn and cmpNotIn conditions to test a property’s actual value against comma-separated, pipe-separated lists, and so on, that is, to check whether the actual value equals (or does not equal) to any value stored on the list. For example, you can use the cmpIn condition to check whether the value of the Sys.OSInfo.Name property that contains the name of the currently running operating system belongs to the comma-separated list "Win7,WinVista,Win2008":

    JavaScript, JScript

    aqObject.CheckProperty(Sys.OSInfo, "Name", cmpIn, "Win7,WinVista,Win2008");

    Python

    aqObject.CheckProperty(Sys.OSInfo, "Name", cmpIn, "Win7,WinVista,Win2008")

    VBScript

    Call aqObject.CheckProperty(Sys.OSInfo, "Name", cmpIn, "Win7,WinVista,Win2008")

    DelphiScript

    aqObject.CheckProperty(Sys.OSInfo, 'Name', cmpIn, 'Win7,WinVista,Win2008');

    C++Script, C#Script

    aqObject["CheckProperty"](Sys["OSInfo"], "Name", cmpIn, "Win7,WinVista,Win2008");
  • To verify an object property's value, you can also use the CompareProperty method.

See Also

About Property Checkpoints
Alternatives to Property Checkpoints

Highlight search results