WaitAliasChild Method

Applies to TestComplete 14.71, last modified on April 22, 2021

Description

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

Use the WaitAliasChild method to delay the test execution until the object specified by its alias appears in the system or until the specified time limit is reached. If the specified object is found, the method returns it; otherwise it returns an “empty” stub object that only has the Exists property.

Declaration

TestObj.WaitAliasChild(ChildNameWaitTime)

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]    Optional    Integer Default value: 0   
Result A mapped object referred to via an alias

Applies To

All mapped processes, windows, controls and the Aliases object.

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 alias of the desired child object, as it is defined in the Aliases section of the NameMapping editor. This alias must be a child item of the AliasObj in the Aliases tree.

Note: The alias is always case-insensitive, in spite of the value of the Use case-sensitive parameters project option.

WaitTime

The time period, in milliseconds, to wait until the specified object becomes available. If WaitTime is 0, the method searches for the specified object once and returns immediately. If WaitTime is -1, the waiting time is specified by the Auto-wait timeout project setting.

Result Value

The child object that has the specified alias. If the specified object does not exist, the method returns a stub object and the method does not post an error message to the log, unlike when you directly refer to a mapped object by an alias. To determine whether the returned object exists in the system, use its Exists property.

Example

The code below waits until the Font window of the Notepad application appears for 10 seconds. If the window is displayed, the routine posts an informative message to the test log; otherwise, an error occurs.

JavaScript, JScript

function WaitAliasChildExample()
{
  // Specifies the Alias object
  var AliasObj = Aliases.notepad;
  // Checks whether the Font window has appeared within 10 seconds
  if (AliasObj.WaitAliasChild("dlgFont", 10000).Exists )
    Log.Message("The Font window has appeared")
  else
    Log.Error("The Font window has not appeared.");
}

Python

def WaitAliasChildExample():
  # Specifies the Alias object
  AliasObj = Aliases.notepad
  # Checks whether the Font window has appeared within 10 seconds
  if (AliasObj.WaitAliasChild("dlgFont", 10000).Exists): 
    Log.Message("The Font window has appeared")
  else:
    Log.Error("The Font window has not appeared.")

VBScript

Sub WaitAliasChildExample
  ' Specifies the Alias object
  Set AliasObj = Aliases.notepad
  ' Checks whether the Font window has appeared within 10 seconds
  If AliasObj.WaitAliasChild("dlgFont", 10000).Exists Then
    Log.Message("The Font window has appeared")
  Else
    Log.Error("The Font window has not appeared.")
  End If
End Sub

DelphiScript

function WaitAliasChildExample;
var AliasObj;
begin
  // Specifies the Alias object
  AliasObj := Aliases.notepad;
  // Checks whether the Font window has appeared within 10 seconds
  if (AliasObj.WaitAliasChild('dlgFont', 10000).Exists ) then
    Log.Message('The Font window has appeared')
  else
    Log.Error('The Font window has not appeared.');
end;

C++Script, C#Script

function WaitAliasChildExample()
{
  // Specifies the Alias object
  var AliasObj = Aliases["notepad"];
  // Checks whether the Font window has appeared within 10 seconds
  if (AliasObj["WaitAliasChild"]( "dlgFont", 10000 )["Exists"] )
    Log["Message"]("The Font window has appeared")
  else
    Log["Error"]("The Font window has not appeared.");
}

See Also

Exists Property
RefreshMappingInfo Method
WaitNamedChild Method
Name Mapping

Highlight search results