ChildDataByIndex Property

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

Description

A table row can have child data (do not confuse child data with child rows). This is the data displayed in additional log panels when you select the given table row. For example, in the case of the table in the Test Log pane of the generic script log, the child datasets for the table row are data that is displayed in the Details and Picture panels.

The ChildDataByIndex property returns the child dataset of the given table row. The dataset to obtain is specified by its index.

The total number of child datasets is specified by the LogDataScheme.ChildCount property.

Declaration

LogTableRowObj.ChildDataByIndex(Index)

Read-Only Property A LogTableData, TextLogData or PictureLogData object
LogTableRowObj An expression, variable or parameter that specifies a reference to a LogTableRow object
Index [in]    Required    Integer    

Applies To

The property is applied to the following object:

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 child dataset is LogDataScheme.ChildCount - 1.

Property Value

A LogTableData, TextLogData or PictureLogData object, which contains the desired log item’s data. To determine the type of the resulting object, use its Scheme.DataType property.

Remarks

If you use Python or DelphiScript, you should enclose the parameter of the ChildDataByIndex property in square brackets: ChildDataByIndex[Index].

You can also obtain the child dataset for the given row using the ChildData or ChildDataByName property.

Example

The following example demonstrates how to obtain a row’s child dataset for data displayed in the Details panel and how to export that data to an external file.

JavaScript

function TableDataRowSample()
{
  // Obtains a log item
  var Logs = Project.Logs;
  var LogItem = Logs.LogItem(0);
  // Obtains the log item’s dataset
  var LogData = LogItem.Data(0);

  var DType = LogData.Scheme.DataType;
  // Checks whether the dataset corresponds to the table
  if (DType == 0)
  {
    // Obtains a table row by its index
    var Row = LogData.Rows(0);

    // Obtains the dataset by its index
    var ChildDataSet = Row.ChildDataByIndex(1);
    // Checks whether the dataset is TextLogData
    if (ChildDataSet.Scheme.DataType == 1)

    {
      // Specifies an external file to export the text to
      var ExportFileName = "D:\\Work Folder\\ExportedLog\\Details.html";

      // Exports the text from the Details panel to the external file
      FS = getActiveXObject("Scripting.FileSystemObject");
      ExportFile = FS.CreateTextFile(ExportFileName, true);
      ExportFile.WriteLine(ChildDataSet.Text);
      ExportFile.Close();
    }

  }

}

JScript

function TableDataRowSample()
{
  // Obtains a log item
  var Logs = Project.Logs;
  var LogItem = Logs.LogItem(0);
  // Obtains the log item’s dataset
  var LogData = LogItem.Data(0);

  var DType = LogData.Scheme.DataType;
  // Checks whether the dataset corresponds to the table
  if (DType == 0)
  {
    // Obtains a table row by its index
    var Row = LogData.Rows(0);

    // Obtains the dataset by its index
    var ChildDataSet = Row.ChildDataByIndex(1);
    // Checks whether the dataset is TextLogData
    if (ChildDataSet.Scheme.DataType == 1)

    {
      // Specifies an external file to export the text to
      var ExportFileName = "D:\\Work Folder\\ExportedLog\\Details.html";

      // Exports the text from the Details panel to the external file
      FS = Sys.OleObject("Scripting.FileSystemObject");
      ExportFile = FS.CreateTextFile(ExportFileName, true);
      ExportFile.WriteLine(ChildDataSet.Text);
      ExportFile.Close();
    }

  }

}

Python

def TableDataRowSample():
  # Obtains a log item
  Logs = Project.Logs
  LogItem = Logs.LogItem[0]
  # Obtains the log item's dataset
  LogData = LogItem.Data[0]
  DType = LogData.Scheme.DataType
  # Checks whether the dataset corresponds to the table
  if DType == 0:
    # Obtains a table row by its index
    Row = LogData.Rows[0]
    # Obtains the dataset by its index
    ChildDataSet = Row.ChildDataByIndex[1]
    # Checks whether the dataset is TextLogData
    if ChildDataSet.Scheme.DataType == 1:
      # Specifies an external file to export the text to
      ExportFileName = "D:\\Work Folder\\ExportedLog\\AdditionalInfo.html"
      # Exports the text from the Additional Info panel to the external file
      FS = Sys.OleObject["Scripting.FileSystemObject"]
      ExportFile = FS.CreateTextFile(ExportFileName, True)
      ExportFile.WriteLine(ChildDataSet.Text)
      ExportFile.Close()

VBScript

Sub TableDataRowSample

  ' Obtains a log item
  Set Logs = Project.Logs
  Set LogItem = Logs.LogItem(0)
  ' Obtains the log item’s dataset
  Set LogData = LogItem.Data(0)

  DType = LogData.Scheme.DataType
  ' Checks whether the dataset corresponds to the table
  If DType = 0 Then
    ' Obtains a table row by its index
    Set Row = LogData.Rows(0)

    ' Obtains the dataset by its index
    Set ChildDataSet = Row.ChildDataByIndex(1)
    ' Checks whether the dataset is TextLogData
    If ChildDataSet.Scheme.DataType = 1 Then

      ' Specifies an external file to export the text to
      ExportFileName = "D:\Work Folder\ExportedLog\Details.html"

      ' Exports the text from the Details panel to the external file
      Set FS = Sys.OleObject("Scripting.FileSystemObject")
      Set ExportFile = FS.CreateTextFile(ExportFileName, True)
      ExportFile.WriteLine ChildDataSet.Text
      ExportFile.Close
    End If

  End If

End Sub

DelphiScript

procedure TableDataRowSample();
var
  Logs, LogItem, LogData, DType, Row, ChildDataSet, ExportFile, ExportFileName;
begin
  // Obtains a log item
  Logs := Project.Logs;
  LogItem := Logs.LogItem(0);
  // Obtains the log item’s dataset
  LogData := LogItem.Data(0);

  DType := LogData.Scheme.DataType;
  // Checks whether the dataset corresponds to the table
  if DType = 0 then
  begin
    // Obtains a table row by its index
    Row := LogData.Rows[0];

    // Obtains the dataset by its index
    ChildDataSet := Row.ChildDataByIndex[1];
    // Checks whether the dataset is TextLogData
    if ChildDataSet.Scheme.DataType = 1 then

    begin
      // Specifies an external file to export the text to
      ExportFileName := 'D:\Work Folder\ExportedLog\Details.html';

      // Exports the text from the Details panel to the external file
      AssignFile(ExportFile, ExportFileName);
      Rewrite(ExportFile);
      WriteLn(ExportFile, ChildDataSet.Text);
      CloseFile(ExportFile);
    end;

  end;

end;

C++Script, C#Script

function TableDataRowSample()
{
  // Obtains a log item
  var Logs = Project["Logs"];
  var LogItem = Logs["LogItem"](0);
  // Obtains the log item’s dataset
  var LogData = LogItem["Data"](0);

  var DType = LogData["Scheme"]["DataType"];
  // Checks whether the dataset corresponds to the table
  if (DType == 0)
  {
    // Obtains a table row by its index
    var Row = LogData["Rows"](0);

    // Obtains the dataset by its index
    var ChildDataSet = Row["ChildDataByIndex"](1);
    // Checks whether the dataset is TextLogData
    if (ChildDataSet["Scheme"]["DataType"] == 1)

    {
      // Specifies an external file to export the text to
      var ExportFileName = "D:\\Work Folder\\ExportedLog\\Details.html";

      // Exports the text from the Details panel to the external file
      FS = Sys["OleObject"]("Scripting.FileSystemObject");
      ExportFile = FS["CreateTextFile"](ExportFileName, true);
      ExportFile["WriteLine"](ChildDataSet["Text"]);
      ExportFile["Close"]();
    }

  }

}

See Also

Access Test Log Contents from Tests
ChildData Property
ChildDataByName Property
ChildCount Property

Highlight search results