ChildDataByName Property

Applies to TestComplete 14.92, last modified on September 16, 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 ChildDataByName property returns the child dataset of the given table row. The dataset to obtain is specified by its name.

Declaration

LogTableRowObj.ChildDataByName(DataName)

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

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

DataName

The name of the desired child dataset. Usually the dataset name is the string displayed in the caption of the corresponding test log panel, for example, Picture, Connections and so on.

Property Value

A LogTableData, TextLogData or PictureLogData object which contains the desired child dataset. 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 ChildDataByName property in square brackets: ChildDataByName[DataName].

You can also obtain the desired child dataset using the ChildData or ChildDataByIndex 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 name
    var ChildDataSet = Row.ChildDataByName("Details");
    // 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 name
    var ChildDataSet = Row.ChildDataByName("Details");
    // 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 name
    ChildDataSet = Row.ChildDataByName["Details"]
    # 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\\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()

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 name
    Set ChildDataSet = Row.ChildDataByName("Details")
    ' 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 name
    ChildDataSet := Row.ChildDataByName['Details'];
    // 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 name
    var ChildDataSet = Row["ChildDataByName"]("Details");
    // 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
ChildDataByIndex Property

Highlight search results