Description
Use the WaitProperty
method to pause the test execution until the specified object property achieves the specified value or until the specified timeout elapses.
Declaration
TestObj.WaitProperty(PropertyName, PropertyValue, WaitTime)
TestObj | A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section | |||
PropertyName | [in] | Required | String | |
PropertyValue | [in] | Required | Variant | |
WaitTime | [in] | Optional | Integer | Default value: -1 |
Result | Boolean |
Applies To
All processes, windows, controls and onscreen objects.
View Mode
This method is available in the Object Browser panel and in other panels and dialogs in both Basic and Advanced view modes.
Parameters
The method has the following parameters:
PropertyName
The name of the desired property.
PropertyValue
The property value to wait for before continuing the test execution.
You can enter the item’s index (from 0) or its caption.
The caption can contain wildcards or regular expressions:
-
The asterisk (*) wildcard corresponds to a string of any length (including an empty string).
-
The question mark (?) wildcard corresponds to any single character (including none).
-
To specify more complicated sought-for patterns for the caption, use regular expressions in the following format:
regexp:<pattern>
. For example,regexp:gr[ae]y
.Use standard TestComplete (non-native) syntax to specify regular expressions. The property does not support native regular expression syntax, that is, the syntax provided by scripting languages.
Notes:
-
The caption can be case-sensitive or case-insensitive depending on the Use case-sensitive parameters project setting. The regular expression patterns are always case-insensitive. For example,
"regexp:gr[ae]y"
will match both "gray" and "GRAY". -
Patterns search for partial matches. For example,
regexp:notepad
matches both "notepad" and "notepad++". To search for an exact match, use the ^ and $ anchors, for example "regexp:^notepad$".
For detailed information on regular expression syntax, see Regular Expressions Syntax .
-
WaitTime
The number of milliseconds to wait for the specified property value. If WaitTime is 0, the method does not wait and returns immediately. If WaitTime is -1, the waiting time is specified by the Auto-wait timeout project property.
Note: If you are testing an Open Application, the WaitTime parameter is required. In case of a non-Open Application, the WaitTime parameter is optional and has the default value 0.
Result Value
If the property achieves the specified value within the timeout, the method returns True. Otherwise, if the timeout elapses before the property achieves the specified value, the method returns False.
Also, False if the object does not have the specified property.
Remarks
-
The
WaitProperty
method does not support indexed properties (that is, properties that require parameters). To wait until an indexed property becomes equal to a specific value, you can use a loop like the following:JavaScript, JScript
while (statusBarObj.wText(0) != "Ready")
{
aqUtils.Delay(100);
statusBarObj.Refresh();
}Python
while (statusBarObj.wText(0) != "Ready"):
aqUtils.Delay(100)
statusBarObj.Refresh()VBScript
While statusBarObj.wText(0) <> "Ready"
aqUtils.Delay 100
statusBarObj.Refresh
WendDelphiScript
while statusBarObj.wText[0] <> 'Ready' do
begin
aqUtils.Delay(100);
statusBarObj.Refresh;
end;C++Script, C#Script
while (statusBarObj["wText"](0) != "Ready")
{
aqUtils["Delay"](100);
statusBarObj["Refresh"]();
}
Example
The following example demonstrates how to use the WaitProperty
method in scripts:
JavaScript, JScript
var btn = Sys.Process("MyApp").Window("TMainFrm","MyApplication
*").Child(2);
if (btn.WaitProperty("Enabled", true, 2000))
// Button is enabled
else
// Button is disabled
Python
btn = Sys.Process("MyApp").Window("TMainFrm","MyApplication *").Child(2)
if btn.WaitProperty("Enabled", True, 2000):
# Button is enabled
else:
# Button is disabled
VBScript
Set btn = Sys.Process("MyApp").Window("TMainFrm","MyApplication
*").Child(2)
If btn.WaitProperty("Enabled", True, 2000) Then
' Button is enabled
Else
' Button is disabled
End If
DelphiScript
var
btn : OleVariant;
begin
btn := Sys.Process('MyApp').Window('TMainFrm','MyApplication *').Child(2);
if btn.WaitProperty('Enabled', true, 2000) then
// Button is enabled
else
// Button is disabled
end;
C++Script, C#Script
var btn = Sys["Process"]("MyApp")["Window"]("TMainFrm","MyApplication
*")["Child"](2);
if (btn["WaitProperty"]("Enabled", true, 2000))
// Button is enabled
else
// Button is disabled