ChildCount Property

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

Data displayed in the TestComplete test log can have child data. For example, the child data for a single message in the generic script log is the corresponding data displayed in the Details and Picture panels.

The ChildCount property specifies the total number of child datasets of the dataset specified by the ProgObj object, which contains the dataset’s scheme.

Declaration

ProgObj.ChildCount

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

Applies To

The property is applied to the following objects:

Property Value

The total number of child datasets of the dataset specified by the ProgObj.

Remarks

To obtain a desired child dataset of a log table row, use the ChildData, ChildDataByIndex or ChildDataByName property of the corresponding LogTableRow object.

Example

The code below obtains the total number of child elements that belong to the specified scheme and then posts the names of all the child datasets to the test log.

JavaScript, JScript

function LogDataSchemeExample()
{
  // Obtains a collection of logs
  var LogsCol = Project.Logs;
  // Obtains the first log item
  var LogItem = LogsCol.LogItem(0);
  // Obtains the first dataset
  // of the specified log item
  var LogData = LogItem.Data(0);
  // Obtains the scheme of the dataset
  var Sch = LogData.Scheme;
  // Obtains the number of child
  // datasets that belong to the scheme
  var Num = Sch.ChildCount;
  
  if ( Num > 0 )
  {
    // Iterates through the child datasets
    for (var i = 0; i < Num; i++)
    {
      var dataItem = Sch.Child(i);
      // Obtains the name of the current child dataset
      var dataName = dataItem.Name;
      Log.Message(dataName);
    }
  }
  else
    Log.Message("The dataset has no child elements.");
}

Python

def LogDataSchemeExample():
  # Obtains a collection of logs
  LogsCol = Project.Logs
  # Obtains the first log item
  LogItem = LogsCol.LogItem[0]
  # Obtains the first dataset
  # of the specified log item
  LogData = LogItem.Data[0]
  # Obtains the scheme of the dataset
  Sch = LogData.Scheme
  # Obtains the number of child
  # datasets that belong to the scheme
  Num = Sch.ChildCount
  if Num > 0:
    # Iterates through the child datasets
    for i in range(0, Num):
      dataItem = Sch.Child[i]
      # Obtains the name of the current child dataset
      dataName = dataItem.Name
      Log.Message(dataName)
  else:
     Log.Message("The dataset has no child elements.")

VBScript

Sub LogDataSchemeExample()

  ' Obtains a collection of logs
  Set LogsCol = Project.Logs
  ' Obtains the first log item
  Set LogItem = LogsCol.LogItem(0)
  ' Obtains the first dataset
  ' of the specified log item
  Set LogData = LogItem.Data(0)
  ' Obtains the scheme of the dataset
  Set Sch = LogData.Scheme
  ' Obtains the number of child
  ' datasets that belong to the scheme
  Num = Sch.ChildCount
  
  If Num > 0 Then
    ' Iterates through the child datasets
    For i = 0 to (Num - 1)
      Set dataItem = Sch.Child(i)
      ' Obtains the name of the current child dataset
      dataName = dataItem.Name
      Log.Message(dataName)
    Next 
  Else
    Log.Message("The dataset has no child elements.")
  End If
     
End Sub

DelphiScript

function LogDataSchemeExample;
var LogsCol, LogItem, LogData, Sch, Num, i, dataItem, dataName;
begin

  // Obtains a collection of logs
  LogsCol := Project.Logs;
  // Obtains the first log item
  LogItem := LogsCol.LogItem[0];
  // Obtains the first dataset
  // of the specified log item
  LogData := LogItem.Data[0];
  // Obtains the scheme of the dataset
  Sch := LogData.Scheme;
  // Obtains the number of child
  // datasets that belong to the scheme
  Num := Sch.ChildCount;
  
  if ( Num > 0 ) then
  begin
    // Iterates through the child datasets
    for i := 0 to (Num - 1) do
    begin
      dataItem := Sch.Child[i];
      // Obtains the name of the current child dataset
      dataName := dataItem.Name;
      Log.Message(dataName);
    end;
  end
  else
    Log.Message('The dataset has no child elements.');

end;

C++Script, C#Script

function LogDataSchemeExample()
 {
   // Obtains a collection of logs
   var LogsCol = Project["Logs"];
   // Obtains the first log item
   var LogItem = LogsCol["LogItem"](0);
   // Obtains the first dataset
   // of the specified log item
   var LogData = LogItem["Data"](0);
   // Obtains the scheme of the dataset
   var Sch = LogData["Scheme"];
   // Obtains the number of child
   // datasets that belong to the scheme
   var Num = Sch["ChildCount"];
   
   if ( Num > 0 )
   {
     // Iterates through the child datasets
     for (var i = 0; i < Num; i++)
     {
       var dataItem = Sch["Child"](i);
       // Obtains the name of the current child dataset
       var dataName = dataItem["Name"];
       Log["Message"](dataName);
     }
   }
   else
     Log["Message"]("The dataset has no child elements.");
 }

See Also

Access Test Log Contents from Tests
Child Property
DataType Property
Name Property
LogTableRow Object

Highlight search results