Text Property

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

Description

The Text property returns the text stored in the log and represented by the given TextLogData object. To determine the text format, use the Format property.

Declaration

TextLogDataObj.Text

Read-Only Property String
TextLogDataObj An expression, variable or parameter that specifies a reference to a TextLogData object

Applies To

The property is applied to the following object:

Property Value

The string holding the stored text.

Example

The following example demonstrated how you can obtain the text stored in the test log.

JavaScript

function ExportTest()
{

  var Logs, LogItem, DataSet, ExportFileName;
  // Obtains project logs
  Logs = Project.Logs;
  // Obtains the desired log item
  LogItem = Logs.LogItem(0);
  // Obtains a dataset stored in the log
  DataSet = LogItem.Data(1);

  // Checks if the dataset stores text data
  if (DataSet.Scheme.DataType == ldtText)
    {
    ExportFileName = "D:\\Work Folder\\ExportedLog\\ExportLog.txt";
    // Exports the text from the log to an external file
    FS = getActiveXObject("Scripting.FileSystemObject");
    ExportFile = FS.CreateTextFile(ExportFileName, True);

    ExportFile.WriteLine(DataSet.Text);

    ExportFile.Close();
    }

}

JScript

function ExportTest()
{

  var Logs, LogItem, DataSet, ExportFileName;
  // Obtains project logs
  Logs = Project.Logs;
  // Obtains the desired log item
  LogItem = Logs.LogItem(0);
  // Obtains a dataset stored in the log
  DataSet = LogItem.Data(1);

  // Checks if the dataset stores text data
  if (DataSet.Scheme.DataType == ldtText)
    {
    ExportFileName = "D:\\Work Folder\\ExportedLog\\ExportLog.txt";
    // Exports the text from the log to an external file
    FS = Sys.OleObject("Scripting.FileSystemObject");
    ExportFile = FS.CreateTextFile(ExportFileName, True);

    ExportFile.WriteLine(DataSet.Text);

    ExportFile.Close();
    }

}

Python

def ExportTest():
  # Obtains project logs 
  Logs = Project.Logs
  # Obtains the desired log item 
  LogItem = Logs.LogItem[0]
  # Obtains a dataset stored in the log 
  DataSet = LogItem.Data[1]
  # Checks if the dataset stores text data 
  if DataSet.Scheme.DataType == ldtText:
    ExportFileName = "D:\\Work Folder\\ExportedLog\\ExportLog.txt"
    # Exports the text from the log to an external file 
    FS = Sys.OleObject["Scripting.FileSystemObject"]
    ExportFile = FS.CreateTextFile(ExportFileName, True)
    ExportFile.WriteLine(DataSet.Text)
    ExportFile.Close()

VBScript

Sub ExportTest

  Dim Logs, LogItem, DataSet, ExportFileName
  ' Obtains project logs
  Set Logs = Project.Logs
  ' Obtains the desired log item
  Set LogItem = Logs.LogItem(0)
  ' Obtains a dataset stored in the log
  Set DataSet = LogItem.Data(1)

  ' Checks if the dataset stores text data
  If DataSet.Scheme.DataType = ldtText Then
    ExportFileName = "D:\Work Folder\ExportedLog\ExportLog.txt"
    ' Exports the text from the log to an external file
    Set FS = Sys.OleObject("Scripting.FileSystemObject")
    Set ExportFile = FS.CreateTextFile(ExportFileName, True)

    ExportFile.WriteLine DataSet.Text

    ExportFile.Close
  End If

End Sub

DelphiScript

procedure ExportTest();
var Logs, LogItem, DataSet, ExportFile, ExportFileName;
begin

  // Obtains project logs
  Logs := Project.Logs;
  // Obtains the desired log item
  LogItem := Logs.LogItem(0);
  // Obtains a dataset stored in the log
  DataSet := LogItem.Data(1);

  // Checks if the dataset stores text data
  if DataSet.Scheme.DataType = ldtText then
    begin
    ExportFileName := 'D:\Work Folder\ExportedLog\ExportLog.txt';
    // Exports the text from the log to an external file
    AssignFile(ExportFile, ExportFileName);
    Rewrite(ExportFile);

    WriteLn(ExportFile, DataSet.Text);

    CloseFile(ExportFile);
    end;

end;

C++Script, C#Script

function ExportTest()
{

  var Logs, LogItem, DataSet, ExportFileName;
  // Obtains project logs
  Logs = Project["Logs"];
  // Obtains the desired log item
  LogItem = Logs["LogItem"](0);
  // Obtains a dataset stored in the log
  DataSet = LogItem["Data"](1);

  // Checks if the dataset stores text data
  if (DataSet["Scheme"]["DataType"] == ldtText)
    {
    ExportFileName = "D:\\Work Folder\\ExportedLog\\ExportLog.txt";
    // Exports the text from the log to an external file
    FS = Sys["OleObject"]("ScriptingFileSystemObject");
    ExportFile = FS["CreateTextFile"](ExportFileName, true);

    ExportFile["WriteLine"](DataSet["Text"]);

    ExportFile["Close"]();
    }

}

You can also view an example in the Access Test Log Contents from Tests topic.

See Also

Access Test Log Contents from Tests
Format Property

Highlight search results