The pith and marrow of any testing lies in the execution of various kinds of checks. In this recipe we will come to grips with the simplest type of checks: property checkpoint.
This means that for a selected object we check the value of a certain property (for example, text, availability, visibility, and so on).
Launch the Calculator Plus application (C:Program FilesMicrosoft Calculator PlusCalcPlus.exe
).
In order to create a property checkpoint we need to perform the following steps:
As a result, the Create Property Checkpoint window will show up on the screen.
function Test1() { var wndSciCalc; wndSciCalc = Sys.Process("CalcPlus").Window("SciCalc", "Calculator Plus"); wndSciCalc.Window("Button", "2").ClickButton(); wndSciCalc.Window("Button", "+").ClickButton(); wndSciCalc.Window("Button", "5").ClickButton(); wndSciCalc.Window("Button", "=").ClickButton(); var field = wndSciCalc.Window("Edit", "", 1); aqObject.CheckProperty(field, "wText", cmpEqual, "7, "); }
CheckProperty
. When the message is selected in the log, on the Additional Info tab, we would see the detailed description of the checkpoint.In the first several lines of code, we simply click on the buttons. The check itself is executed by the method aqObject.CheckProperty
, in which function call was properly generated for us by the wizard.
The method
CheckProperty
receives four parameters:
Equals
type); however, it is also possible to use other types. For example, for the line, it is possible to check if a substring matches the line, and if it begins or ends with a specifically signified substring. For digits, one could apply fewer types of comparison. Altogether, there are about 16 types of tests.If the test fails, the log will contain substantial information on the possible reasons for the errors.
Apart from the method
aqObject.CheckProperty
there is a similar function aqObject.CompareProperty
. The difference is in the accepted parameters: the CompareProperty
method takes property as a parameter and it's not the object or the property as in case of the CheckProperty
method. Moreover, the CompareProperty
method has another parameter, MessageType
, which allows it to assign, which type of message will be generated in the event of a failure (an error, a warning, or an ordinary notification).
3.149.249.252