Applies to TestComplete 14.60, last modified on September 18, 2020

Description

The NamedChild property is added to any object that is mapped with the Name Mapping feature.

Use the NamedChild property to obtain a child mapping item of the mapped object.

Declaration

TestObj.NamedChild(Index)

Read-Only Property A mapped object
TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
Index [in]    Required    Integer    

Applies To

To all mapped processes, windows and controls.

View Mode

This property is not displayed in the Object Browser panel.

Parameters

The property has the following parameter:

Index

Specifies the index of the desired child item in the collection of child items of the mapped object. The index is zero-based. Use the NamedChildCount property to obtain the total number of child items.

Property Value

The specified mapped object.

Remarks

If you use Python or DelphiScript, you should enclose the parameter of the NamedChild property in square brackets: NamedChild[Index].

Example

The following example posts descriptions of the Sys mapped object and its child objects to the test log.

JavaScript, JScript

function NameMappingSample()
{
  var MappedObj, Desc, Item;
  // Obtains the Sys mapped object
  MappedObj = NameMapping.Sys;
  Log.AppendFolder(MappedObj.MappedName, MappedObj.NodeDescription);
  // Iterates through the child mapping items
  // Posts their names and descriptions to the test log
  for (var i = 0; i < MappedObj.NamedChildCount; i++)
  {
    Item = MappedObj.NamedChild(i);
    Log.Message(Item.MappedName, Item.NodeDescription);
  }
  Log.PopLogFolder();

}

Python

def NameMappingSample():
  # Obtains the Sys mapped object
  MappedObj = NameMapping.Sys
  Log.AppendFolder(MappedObj.MappedName, MappedObj.NodeDescription)
  # Iterates through the child mapping items
  # Posts their names and descriptions to the test log
  for i in range (0, MappedObj.NamedChildCount):
    Item = MappedObj.NamedChild[i]
    Log.Message(Item.MappedName, Item.NodeDescription)
  Log.PopLogFolder()

VBScript

Sub NameMappingSample

  ' Obtains the Sys mapped object
  Set MappedObj = NameMapping.Sys
  Call Log.AppendFolder(MappedObj.MappedName, MappedObj.NodeDescription)
  ' Iterates through the child mapping items
  ' Posts their names and descriptions to the test log
  For i = 0 To MappedObj.NamedChildCount - 1
    Set Item = MappedObj.NamedChild(i)
    Call Log.Message(Item.MappedName, Item.NodeDescription)
  Next
  Log.PopLogFolder

End Sub

DelphiScript

procedure NameMappingSample();
var
  MappedObj, Item : OleVariant;
  Desc : string;
  i : integer;
begin
  // Obtains the Sys mapped object
  MappedObj := NameMapping.Sys;
  Log.AppendFolder(MappedObj.MappedName, MappedObj.NodeDescription);
  // Iterates through the child mapping items
  // Posts their names and descriptions to the test log
  for i := 0 to MappedObj.NamedChildCount - 1 do
  begin
    Item := MappedObj.NamedChild[i];
    Log.Message(Item.MappedName, Item.NodeDescription);
  end;
  Log.PopLogFolder;

end;

C++Script, C#Script

function NameMappingSample()
{
  var MappedObj, Desc, Item;
  // Obtains the Sys mapped object
  MappedObj = NameMapping["Sys"];
  Log["AppendFolder"](MappedObj["MappedName"], MappedObj["NodeDescription"]);
  // Iterates through the child mapping items
  // Posts their names and descriptions to the test log
  for (var i = 0; i < MappedObj["NamedChildCount"]; i++)
  {
    Item = MappedObj["NamedChild"](i);
    Log["Message"](Item["MappedName"], Item["NodeDescription"]);
  }
  Log["PopLogFolder"]();

}

See Also

Name Mapping
NamedChildCount Property

Highlight search results