RemoveNamedChild Method

Applies to TestComplete 15.45, last modified on December 01, 2022

Description

The RemoveNamedChild method is added to any object that is mapped with the Name Mapping feature.

Use the RemoveNamedChild method to remove a mapped object along with all of its child mapped objects from your project’s Name Mapping item. The method call must be applied to the parent mapped object of the object branch that you want to remove.

Declaration

TestObj.RemoveNamedChild(Index)

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    
Result None

Applies To

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 parameter:

Index

A zero-based index of the mapped object you want to remove among child objects of the current mapped object. The total number of a mapped object’s child objects is specified by the NamedChildCount property.

Result Value

None.

Remarks

The method removes mapped objects along with their aliases.

Example

The following code snippet iterates through the Sys mapped object’s child items and deletes them.

JavaScript, JScript

function NameMappingSample()
{
  var SysMappedObj = NameMapping.Sys;
  // Iterates through the mapped Sys object’s child items
  // And deletes them
  while (SysMappedObj.NamedChildCount > 0)
  {
    var Indx = SysMappedObj.NamedChildCount - 1;
    SysMappedObj.RemoveNamedChild(Indx);
  }

}

Python

def NameMappingSample():
  SysMappedObj = NameMapping.Sys
  # Iterates through the mapped Sys object's child items
  # And deletes them
  while (SysMappedObj.NamedChildCount > 0):
    Indx = SysMappedObj.NamedChildCount - 1
    SysMappedObj.RemoveNamedChild(Indx)

VBScript

Sub NameMappingSample

  Set SysMappedObj = NameMapping.Sys
  ' Iterates through the mapped Sys object’s child items
  ' And deletes them
  While SysMappedObj.NamedChildCount > 0
    Indx = SysMappedObj.NamedChildCount - 1
    SysMappedObj.RemoveNamedChild(Indx)
  Wend

End Sub

DelphiScript

procedure NameMappingSample();
var SysMappedObj, Indx;
begin
  SysMappedObj := NameMapping.Sys;
  // Iterates through the mapped Sys object’s child items
  // And deletes them
  while SysMappedObj.NamedChildCount > 0 do
  begin
    Indx := SysMappedObj.NamedChildCount - 1;
    SysMappedObj.RemoveNamedChild[Indx];
  end;

end;

C++Script, C#Script

function NameMappingSample()
{
  var SysMappedObj = NameMapping["Sys"];
  // Iterates through the mapped Sys object’s child items
  // And deletes them
  while (SysMappedObj["NamedChildCount"] > 0)
  {
    var Indx = SysMappedObj["NamedChildCount"] - 1;
    SysMappedObj["RemoveNamedChild"](Indx);
  }

}

See Also

Delete Mapped Objects From Tests
Name Mapping
AddNamedChild Method

Highlight search results