LogTableData Object

Applies to TestComplete 15.45, last modified on December 01, 2022

Description

A test log can store three types of data: table, text and picture. The LogTableData object lets you work with the data of the table type, which is stored in the log. This can be, for example, the tree-like log table in the Test Log panel of the generic test log.

The LogTableData object contains properties that let you iterate through table rows and access single rows.

To obtain the LogTableData object from scripts, use the Data property of the LogItem object. Make sure that the LogItem.Data.Scheme.DataType property corresponds to the table data type.

Members

Example

The code below obtains the total number of the specified log item's rows and then posts the values of all the rows to the test log.

JavaScript, JScript

function LogTableDataExample()
{
  // Obtains a collection of logs
  var LogsCol = Project.Logs;
  // Obtains the first log item
  var LogItem = LogsCol.LogItem(0);
  // Obtains the first dataset
  var DataSet = LogItem.Data(0);
  
  // Obtains the total number of rows in the dataset
  var Num = DataSet.RowCount;
  // Iterates through the rows
  for (var i = 0; i < Num; i++)
  {
    var Row = DataSet.Rows(i);
    // Obtains the message of the current row
    var Val = Row.ValueByName("Message");
    Log.Message(Val);
  }
}

Python

def LogTableDataExample():
  # Obtains a collection of logs
  LogsCol = Project.Logs
  # Obtains the first log item
  LogItem = LogsCol.LogItem[0]
  # Obtains the first dataset
  DataSet = LogItem.Data[0]
  # Obtains the total number of rows in the dataset
  Num = DataSet.RowCount
  for i in range(0, Num):
    Row = DataSet.Rows[i]
    # Obtains the message of the current row
    Val = Row.ValueByName["Message"]
    Log.Message(Val)

VBScript

Sub LogTableDataExample()

  ' Obtains a collection of logs
  Set LogsCol = Project.Logs
  ' Obtains the first log item
  Set LogItem = LogsCol.LogItem(0)
  ' Obtains the first dataset
  Set DataSet = LogItem.Data(0)
  
  ' Obtains the total number of rows in the dataset
  Num = DataSet.RowCount
  ' Iterates through the rows
  For i = 0 to (Num - 1)
    Set Row = DataSet.Rows(i)
    ' Obtains the message of the current row
    Val = Row.ValueByName("Message")
    Log.Message(Val)
  Next
      
End Sub

DelphiScript

function LogTableDataExample;
var LogsCol, LogItem, DataSet, Num, i, Row, Val;
begin

  // Obtains a collection of logs
  LogsCol := Project.Logs;
  // Obtains the first log item
  LogItem := LogsCol.LogItem[0];
  // Obtains the first dataset
  DataSet := LogItem.Data[0];
  
  // Obtains the total number of rows in the dataset
  Num := DataSet.RowCount;
  // Iterates through the rows
  for i := 0 to (Num - 1) do
  begin
    Row := DataSet.Rows[i];
    // Obtains the message of the current row
    Val := Row.ValueByName('Message');
    Log.Message(Val);
  end;

end;

C++Script, C#Script

function LogTableDataExample()
{
  // Obtains a collection of logs
  var LogsCol = Project["Logs"];
  // Obtains the first log item
  var LogItem = LogsCol["LogItem"](0);
  // Obtains the first dataset
  var DataSet = LogItem["Data"](0);
  
  // Obtains the total number of rows in the dataset
  var Num = DataSet["RowCount"];
  // Iterates through the rows
  for (var i = 0; i < Num; i++)
  {
    var Row = DataSet["Rows"](i);
    // Obtains the message of the current row
    var Val = Row["ValueByName"]("Message");
    Log["Message"](Val);
  }
}

See Also

Access Test Log Contents from Tests
LogTableRow Object
LogColumn Object

Highlight search results