Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Friday 29 March 2019

CheckProperty Method

CheckProperty method Checks whether the actual value of the specified object property matches the specified expected value within the specified timeout.

Syntax-


object.CheckProperty (PropertyName, PropertyValue, [TimeOut])


PropertyName: Required. A String value.

The name of the property whose value is checked. The available properties are listed in the description properties page under each test object.
PropertyValue- Required. A Variant.
The expected value against which the actual property value should be checked. You can either use a simple value or you can use a comparison object together with the value to perform more complex comparisons.
TimeOutOptional. An unsigned long integer value.
The time, in milliseconds, within which UFT should check whether the actual value of the property matches the specified expected value. If no value is specified, UFT uses the time set in the Object Synchronization Timeout option in the Run pane of the Test Settings dialog box.
Default value = 60

Return Type

A Boolean value, Returns TRUE if the property achieves the value, and FALSE if the timeout is reached before the property achieves the value.
A TRUE return value reports a Passed step to the run results; a FALSE return value reports a Failed step to the run results.
NOTE:
If the expected and actual values do not match, an error is reported and the test or component status is changed to failed.
For test run synchronization, or whenever you do not want to fail the test if the expected and actual values do not match, use the WaitProperty method.
Using comparison objects to perform more complex value comparisons.
Using comparison object you can instruct UFT to check whether a specific property value is greater than the specified value.
Syntax:
Object.CheckProperty "items count",micGreaterThan(8)
The following comparison objects can be used:
  • micGreaterThan: Greater than Specifies that UFT checks whether the property value is greater than the specified value.
  • micLessThan: Less than Specifies that UFT checks whether the property value is less than the specified value.
  • micGreaterThanOrEqual: Greater than or equal to Specifies that UFT checks whether the property value is greater than or equal to the specified value.
  • micLessThanOrEqual: Less than or equal to Specifies that UFT checks whether the property value is less than or equal to the specified value.
  • micNotEqual: Not equal to Specifies that UFT checks whether the property value is not equal to the specified value.
  • micRegExpMatch: Regular expression Specifies that UFT checks whether the property value achieves a regular expression match with the specified value. Regular expressions are case-sensitive and must match exactly. 
Note: For example, 'E.*h' matches 'Earth' but not 'The Earth' or 'earth'.


When the types of the expected value and actual value do not match, the comparisons are performed as follows in this below order:
  • Empty values: Empty values may be an uninitialized variable or field (which returns TRUE for the IsNull function in VBscript) or initialized to an empty value (which returns TRUE for the IsEmpty function is VBscript). When trying to compare two arguments when at least one is an empty value, the comparison assumes equality for two uninitialized arguments and for two empty arguments. Any other combination is considered unequal.
Example:

dim vEmpty
Object.CheckProperty "text",micNotEqual(vEmpty)
 

will not wait for the timeout (because the 'text' property value is an empty string and the argument passed to micNotEqual is an empty value, and so micNotEqual finds them not equal and returns TRUE).

  • String values: When trying to compare a string value with non-string value, the string value is converted to the non-string type and then compared. If the string value cannot be converted to the non-string type, the comparison assumes the values are not equal.
Example:

Object.CheckProperty "text",micGreaterThan(8) 

will not wait for the timeout if the 'text' property value is '16' (because micGreaterThan finds 16 to be greater than 8 and returns TRUE), but will wait if the 'text' property value is 'a' (because 'a' cannot be converted to a number).
  • Boolean values: When trying to compare a Boolean value with non-boolean value, the non-boolean value is converted to a boolean value and then compared. The conversion method assumes that any integer value other than '0' is TRUE, and that '0' alone is FALSE. If the conversion fails to produce a boolean value (for example, if the value is 'abc'), the comparison result will be FALSE (note that for the WaitProperty method this result would instruct UFT to keep waiting). If the conversion succeeds, the method compares the two boolean values according to the comparison logic.
  • Other value types: When other value types do not match, they are compared under the assumption that different types are not equal (nor greater than or less than each other).
Note: When working with Mobile objects, you can use this method only for a limited list of properties.
Examples:
1...Check Whether the Text is Entered in an Edit Box..... ?
'The following example uses the CheckProperty method to check whether
'the text "Mercury" is entered in the "Name" edit box.
 
Browser("Nested Lists").Page("Page").WebEdit("Name").Set "Mercury"
Browser("Nested Lists").Page("Page").WebEdit("Name")
.CheckProperty"value","Mercury"

2... Verify the Number of Items in a List..... ?

'The following example uses the CheckProperty method to verify the number of items in a WebList. Note that if the original count is not equal to 15, an error message is displayed in the run results.
Browser("Fill-Out Form Example").Page("Fill-Out Form Example")
.WebList("what-to-do").CheckProperty "items count", 15, TimeLimitation
Item_Count = Browser("Fill-Out Form Example").Page("Fill-Out Form Example")
.WebList("what-to-do").GetROProperty("items count")

If Item_Count = 15 Then 'Remove one item from the list
    Browser("Fill-Out Form Example").Page("Fill-Out Form Example")
   .WebButton("Remove Item From List").Click
    'Check if the item was removed from the list
    Browser("Fill-Out Form Example").Page("Fill-Out Form Example")
   .WebList("what-to-do").CheckProperty "items count", 14, TimeLimitation
Else
    Reporter.ReportEvent micFail,"Number Of List Items",\
                 "The item count in the list should be 15, not " & Item_Count & "." 
End  If

No comments:

Post a Comment

Note: only a member of this blog may post a comment.