Child Property

Applies to TestComplete 15.0, last modified on October 22, 2021

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 Remarks and Picture panels.

The Child property lets you obtain the scheme of the child dataset and thus determine its data type, using the DataType property of the resulting child object.

Declaration

ProgObj.Child(Index)

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

Applies To

The property is applied to the following objects:

Parameters

The property has the following parameter:

Index

The index of the desired child dataset. The index is zero-based, that is, the first dataset has index 0, the second - 1, and so on. Index of the last dataset is ChildCount - 1.

Property Value

A LogDataScheme or LogTableDataScheme object holding the scheme of the desired child dataset. You can use this object to obtain the child dataset of a log table row using the LogTableRow.ChildData property.

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
ChildCount Property
DataType Property
Name Property
ChildData Property

Highlight search results