NamedChildCount Property

Applies to TestComplete 15.48, last modified on March 01, 2023

Description

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

Use this property to obtain the number of child mapping items of the mapped object.

Declaration

TestObj.NamedChildCount

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

Applies To

To all mapped processes, windows and controls.

View Mode

This property is not displayed in the Object Browser panel.

Property Value

An integer value specifying the number of child mapping items.

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

NamedChild Property
Name Mapping

Highlight search results