Applies to TestComplete 14.30, last modified on November 21, 2019

Description

When you refer to a tested mapped object though NameMapping, the resulting object contains the methods and properties of the underlying mapped object, as well as extra members.

Use the WaitNamedChild method to delay the test execution until the specified mapped child object appears in the child list of the given mapped object or the specified time limit is reached. The method then returns the mapped child object, if it is found. Else, it returns an “empty” object. To determine whether the returned object exists in the system, call Exists.

Each mapped object has the WaitNamedChild method.

Declaration

TestObj.WaitNamedChild(MappedChildNameWaitTime)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
MappedChildName [in]    Required    String    
WaitTime [in]    Optional    Integer Default value: 0   
Result A tested object

Applies To

All mapped processes, windows and controls.

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:

MappedChildName

The custom name of the child object as it is defined in the Mapped Objects section of the NameMapping editor (once the object is returned, you can also view its mapped name in the MappedName property). For instance, if you defined the custom name MyProcess for the process object, you should specify MyProcess as the MappedChildName parameter.

Note: The WaitNamedChild method does not accept aliases in the MappedChildName parameter. To wait for a child object specified by an alias, use the WaitAliasChild method.

WaitTime

The number of milliseconds to wait. If this is 0, the method searches for the desired object once and then returns immediately.

Result Value

The child object with the specified custom name. If the specified object does not exist, the method returns an “empty” object.

Example

The following code snippet delays the test execution until Windows Notepad’s process mapped as Notepad becomes available.

JavaScript, JScript

function NameMappingSample()
{
  // Delays the script execution until Windows Notepad becomes available
  var Notepad = NameMapping.Sys.WaitNamedChild("Notepad", 3000);
  if (Notepad.Exists)
  {
    // Performs testing actions over Notepad
    // ...
  }
  else
  {
    Log.Warning("Notepad was not found");
  }

}

Python

def NameMappingSample():
  # Delays the script execution until Windows Notepad becomes available
  Notepad = NameMapping.Sys.WaitNamedChild("Notepad", 3000)
  if (Notepad.Exists):
    # Performs testing actions over Notepad
    # ...
  else:
    Log.Warning("Notepad was not found")

VBScript

Sub NameMappingSample

  ' Delays the script execution until Windows Notepad becomes available
  Set Notepad = NameMapping.Sys.WaitNamedChild("Notepad", 3000)
  If Notepad.Exists Then
    ' Performs testing actions over Notepad
    ' ...
  Else
    Log.Warning "Notepad was not found"
  End If

End Sub

DelphiScript

procedure NameMappingSample();
var Notepad;
begin
  // Delays the script execution until Windows Notepad becomes available
  Notepad := NameMapping.Sys.WaitNamedChild('Notepad', 3000);
  if Notepad.Exists then
  begin
    // Performs testing actions over Notepad
    // ...
  end
  else
    Log.Warning('Notepad was not found');

end;

C++Script, C#Script

function NameMappingSample()
{
  // Delays the script execution until Windows Notepad becomes available
  var Notepad = NameMapping["Sys"]["WaitNamedChild"]("Notepad", 3000);
  if (Notepad["Exists"])
  {
    // Performs testing actions over Notepad
    // ...
  }
  else
  {
    Log["Warning"]("Notepad was not found");
  }

}

See Also

WaitAliasChild Method
Name Mapping
WaitChild Method
Child Method
Find Method
FindChild Method
FindId Method
MappedName Property
Exists Property

Highlight search results