Sometimes, an application may be instrumental in a prolonged routine, during which the test should await its completion. Usually, an application prompts users upon completing the work. One of the examples of the completed operations state is a change of the property of the existing controls element (for example, the button Continue
becomes enabled, background color is changed, and so on).
In this recipe, we will deal with a convenient know-how concerning waiting for the properties to be changed with the help of the
WaitProperty
method.
Launch Calculator Plus (C:Program FilesMicrosoft Calculator PlusCalcPlus.exe
) and make sure it is started in either Standard or in Scientific mode. Make sure that the Digit grouping option from the View tab is unchecked.
Our task is inputting one and the same digit into the calculator (for example, the digit 2) until the value in the text output field is equal to 2222222.
function testWaitProperty() { var expected = "2222222. "; var wCalc = Sys.Process("CalcPlus").Window("SciCalc", "Calculator Plus"); var edit = wCalc.Window("Edit"); wCalc.Activate(); while(!edit.WaitProperty("wText", expected, 1000)) { wCalc.Keys("2"); } }
Expected value contains an extra space character at the end of the string - this happens because the calculator applications add this space so that result wouldn't be too close to the right border of the text field. Users don't notice it, but TestComplete certainly does.
The method WaitProperty
takes three parameters:
If the property has gotten the expected value, the WaitProperty
method returns true
, otherwise, upon expiry of a set time frame, the method returns false
.
This method is recommended for use instead of an ordinary delay (aqUtils.Delay
) in the case that the completion of the monitored operation can be tracked by a given property of any of the controls element.
3.138.67.27