ChildCount Property

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

Description

The TestComplete log consists of log items organized into tree-like structure. The ChildCount property returns the total number of child items of the current log item. To obtain the child log item by its index, use the Child property.

Declaration

LogItemObj.ChildCount

Read-Only Property Integer
LogItemObj An expression, variable or parameter that specifies a reference to a LogItem object

Applies To

The property is applied to the following object:

Property Value

An integer number that signifies the total number of child items of the current log item.

Example

The code below obtains the total number of child elements that belong to the specified log item and then posts this number to the test log.

JavaScript, JScript

function ChildCount()
{
  // Obtains a collection of logs
  var LogsCol = Project.Logs;
  // Obtains the first log item
  var LogItem = LogsCol.LogItem(0);
  
  // Obtains the number of child elements
  // that belong to the log item
  var Num = LogItem.ChildCount;
  Log.Message("The log item has " + Num + " child element(s).");
}

Python

def ChildCount():
  # Obtains a collection of logs
  LogsCol = Project.Logs
  # Obtains the first log item
  LogItem = LogsCol.LogItem[0]
  # Obtains the number of child elements
  # that belong to the log item
  Num = LogItem.ChildCount
  Log.Message("The log item has " + str(Num) + " child element(s).")

VBScript

Sub ChildCount()

  ' Obtains a collection of logs
  Set LogsCol = Project.Logs
  ' Obtains the first log item
  Set LogItem = LogsCol.LogItem(0)
  
  ' Obtains the number of child elements
  ' that belong to the log item
  Num = LogItem.ChildCount
  Log.Message("The log item has " & Num & " child element(s).")
     
End Sub

DelphiScript

function ChildCount;
var LogsCol, LogItem, Num;
begin

  // Obtains a collection of logs
  LogsCol := Project.Logs;
  // Obtains the first log item
  LogItem := LogsCol.LogItem[0];
  
  // Obtains the number of child elements
  // that belong to the log item
  Num := LogItem.ChildCount;
  Log.Message('The log item has ' + Num + ' child element(s).');

end;

C++Script, C#Script

function ChildCount()
{
  // Obtains a collection of logs
  var LogsCol = Project["Logs"];
  // Obtains the first log item
  var LogItem = LogsCol["LogItem"](0);
  
  // Obtains the number of child elements
  // that belong to the log item
  var Num = LogItem["ChildCount"];
  Log["Message"]("The log item has " + Num + " child element(s).");
}

See Also

Access Test Log Contents from Tests
LogItem Object
Child Property
Data Property
DataCount Property

Highlight search results