LogColumn Object

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

Description

Most data in the TestComplete test log are organized into tables. The LogColumn object provides scripting access to a single column of the log table.

To obtain the LogColumn object from scripts, use the Column or ColumnByName property of the LogTableDataScheme object.

Members

Example

The code below obtains the name and data type of the specified test log column using the LogColumn object and its properties.

JavaScript, JScript

function LogColumn()
{
  // 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 information about the third column
  var Column = Sch.Column(2);
  // Obtains the name of the third column
  var Name = Column.Name;
  Log.Message("The " + Name + " column contains the following data:");
  
  // Obtains the data type of the third column
  switch (Column.DataType)
  {
    case ctInteger:
    {
      Log.Message("integer numbers");
      break;
    }
    case ctString:
    {
      Log.Message("strings");
      break;
    }
    case ctFloat:
    {
      Log.Message("floating-point numbers");
      break;
    }
    case ctBoolean:
    {
      Log.Message("boolean values");
      break;
    }
    case ctImage:
    {
      Log.Message("images");
      break;
    }
    case ctHyperlink:
    {
      Log.Message("hyperlinks");
      break;
    }
    case ctDateTime:
    {
      Log.Message("date or time values");
      break;
    }
  }
}

Python

def LogColumn():
  # 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 information about the third column
  Column = Sch.Column[2]
  # Obtains the name of the third column
  Name = Column.Name
  Log.Message("The " + Name + " column contains the following data:") 
  # Obtains the data type of the third column
  if Column.DataType == ctInteger:
    Log.Message("integer numbers")
  elif Column.DataType == ctString:
    Log.Message("strings")
  elif Column.DataType == ctFloat:
    Log.Message("floating-point numbers");
  elif Column.DataType == ctBoolean:
    Log.Message("boolean values")
  elif Column.DataType == ctImage:
    Log.Message("images")
  elif Column.DataType == ctHyperlink:
    Log.Message("hyperlinks")
  elif Column.DataType == ctDateTime:
    Log.Message("date or time values")

VBScript

Sub LogColumn()
  ' 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 information about the third column
  Set Column = Sch.Column(2)
  ' Obtains the name of the third column
  Name = Column.Name
  Log.Message("The " & Name & " column contains the following data:")
  
  ' Obtains the data type of the third column
  Select case Column.DataType
    case ctInteger: Log.Message("integer numbers")
    case ctString: Log.Message("strings")
    case ctFloat: Log.Message("floating-point numbers")
    case ctBoolean: Log.Message("boolean values")
    case ctImage: Log.Message("images")
    case ctHyperlink: Log.Message("hyperlinks")
    case ctDateTime: Log.Message("date or time values")
  End Select
 
End Sub

DelphiScript

function LogColumn;
var LogsCol, LogItem, LogData, Sch, Column, Name;
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 information about the third column
  Column := Sch.Column(2);
  // Obtains the name of the third column
  Name := Column.Name;
  Log.Message('The ' + Name + ' column contains the following data:');
  
  // Obtains the data type of the third column
  case Column.DataType of
    ctInteger: Result : = Log.Message('integer numbers');
    ctString: Result := Log.Message('strings');
    ctFloat: Result := Log.Message('floating-point numbers');
    ctBoolean: Result := Log.Message('boolean values');
    ctImage: Result := Log.Message('images');
    ctHyperlink: Result := Log.Message('hyperlinks');
    ctDateTime: Result := Log.Message('date or time values');
  end;

end;

C++Script, C#Script

function LogColumn()
{
  // 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 information about the third column
  var Column = Sch["Column"](2);
  // Obtains the name of the third column
  var Name = Column["Name"];
  Log["Message"]("The " + Name + " column contains the following data:");
  
  // Obtains the data type of the third column
  switch (Column["DataType"])
  {
    case ctInteger:
    {
      Log["Message"]("integer numbers");
      break;
    }
    case ctString:
    {
      Log["Message"]("strings");
      break;
    }
    case ctFloat:
    {
      Log["Message"]("floating-point numbers");
      break;
    }
    case ctBoolean:
    {
      Log["Message"]("boolean values");
      break;
    }
    case ctImage:
    {
      Log["Message"]("images");
      break;
    }
    case ctHyperlink:
    {
      Log["Message"]("hyperlinks");
      break;
    }
    case ctDateTime:
    {
      Log["Message"]("date or time values");
      break;
    }
  }
}

See Also

Access Test Log Contents from Tests
LogTableDataScheme Object
LogTableRow Object

Highlight search results