LogDataScheme Object

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The structure of log item data is described by data schemes. The scheme holds the dataset name and describes the type and structure of the stored data. To work with data schemes from scripts, the LogDataScheme object is used.

To obtain the dataset’s scheme, use the Scheme property of the corresponding TextLogData or PictureLogData object. To obtain the scheme of the child dataset, you can also use the Child property of the LogDataScheme object holding the parent dataset’s scheme.

Note that data organized in tables and tree lists have specific schemes described by the LogTableDataScheme object. This object contains the same set of properties and also includes additional properties that let you access single table columns and obtain data stored in them.

Members

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
Scheme Property
LogTableDataScheme Object

Highlight search results