WaitChild Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

This method delays script execution until the specified child object appears in the child list or the specified time limit is reached. It then returns the child object if found, else an "empty" object. To determine whether the returned object exists in the system, call the Exists property of this object.

Declaration

TestObj.WaitChild(ChildName, WaitTime)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
ChildName [in]    Required    String    
WaitTime [in]    Required    Integer    
Result Object

Applies To

All processes, windows, controls and onscreen objects.

View Mode

To view this method in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.

Parameters

The method has the following parameters:

ChildName

The name of the child object. This should be the name displayed in the Object Browser panel (in the Name field of the Properties pane).

You can use wildcards (* and ?) in child names. This may be useful if the name of a child object, e.g. a window, changes from one application run to another. To specify an asterisk as part of the name, duplicate the asterisk character (**).

WaitTime

The number of milliseconds to wait for the specified child. If WaitTime is 0, the method does not wait and returns immediately. If WaitTime is -1, the waiting time is infinite.

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

The child object with the specified name. To check if the method returns a valid object, use the Exists property of the returned object. If the property is False, the object is a stub object.

Example

The following example demonstrates how to use the WaitChild method in scripts:

JavaScript, JScript

var p, s;
...
s = "Process(\"WINWORD\")";
p = Sys.WaitChild(s, 10000);
if (p.Exists)
  Log.Message(p.Name);
else
  Log.Message("Not found");

Python

s = 'Process("WINWORD")'
p = Sys.WaitChild(s, 10000)
if p.Exists:
  Log.Message(p.Name)
else:
  Log.Message("Not found")

VBScript

s = "Process(""WINWORD"")"
Set p = Sys.WaitChild(s, 10000)
If p.Exists Then
  Log.Message p.Name
Else
  Log.Message "Not found"
End If

DelphiScript

var s, p;
...
s := 'Process(''WINWORD'')';
p := Sys.WaitChild(s, 10000);
if p.Exists then
  Log.Message(p.Name)
else
  Log.Message('Not found');

C++Script, C#Script

var p, s;
...
s = "[\"Process\"](\"WINWORD\")";
p = Sys["WaitChild"](s, 10000);
if (p["Exists"])
  Log["Message"](p["Name"]);
else
  Log["Message"]("Not found");

See Also

WaitNamedChild
Child Method
Find Method
FindAll Method
FindChild Method
FindAllChildren Method
FindId Method
Name Property
Exists Property

Highlight search results