LogFileParams Object

Applies to TestComplete 14.71, last modified on April 22, 2021

Description

When you post a file or an image to the test log, this file (image) is copied to the folder where results are kept. The LogFileParams object, which is used in the corresponding project events (OnLogFile and OnLogPicture), contains two properties that return source and destination paths to the posted file or image. Therefore, each time the Log.File or Log.Picture method is called, you will definitely know where the file (image) has been copied from and to.

All properties of the LogFileParams object are Read/Write.

Members

Example

The code below posts sample text file to the test log. Then the handler of the OnLogFile event posts both the full path of the actual file and the full path of the stored file to the test log.

Note: Before running the LogFileParams routine, add the OnLogFile event to the list of your project's event controls.

JavaScript, JScript

function LogFileParams()
{
  // Specifies the path to the file
  var sPath = "C:\\Work\\MyFile.txt";
  // Posts the file to the test log
  Log.File(sPath, "The file has been posted to the test log");
}

function EventControl1_OnLogFile(Sender, LogParams, LogFileParams)
{
  // Obtains the full path to the posted file
  var sourPath = LogFileParams.SourceFileName;
  Log.Message("From: " + sourPath);
  // Obtains the full path to the stored file
  var destPath = LogFileParams.DestFileName;
  Log.Message("To: " + destPath);
}

Python

def LogFileParams():
  # Specifies the path to the file 
  sPath = "C:\\Work\\MyFile.txt"
  # Posts the file to the test log
  Log.File(sPath, "The file has been posted to the test log")

def EventControl1_OnLogFile(Sender, LogParams, LogFileParams):
  # Obtains the full path to the posted file
  sourPath = LogFileParams.SourceFileName
  Log.Message("From: " + sourPath)
  # Obtains the full path to the stored file
  destPath = LogFileParams.DestFileName
  Log.Message("To: " + destPath)

VBScript

Sub LogFileParams()
  ' Specifies the path to the file
  sPath = "C:\Work\MyFile.txt"
  ' Posts the file to the test log
  Call Log.File(sPath, "The file has been posted to the test log")
End Sub

Sub EventControl1_OnLogFile(Sender, LogParams, LogFileParams)
  ' Obtains the full path to the posted file
  sourPath = LogFileParams.SourceFileName
  Log.Message("From: " & sourPath)
  ' Obtains the full path to the stored file
  destPath = LogFileParams.DestFileName
  Log.Message("To: " & destPath)
End Sub

DelphiScript

function LogFileParams;
var sPath;
begin

  // Specifies the path to the file
  sPath := 'C:\Work\MyFile.txt';
  // Posts the file to the test log
  Log.File(sPath, 'The file has been posted to the test log');

end;

function EventControl1_OnLogFile(Sender, LogParams, LogFileParams);
var sourPath, destPath;
begin

  // Obtains the full path to the posted file
  sourPath := LogFileParams.SourceFileName;
  Log.Message('From: ' + sourPath);
  // Obtains the full path to the stored file
  destPath := LogFileParams.DestFileName;
  Log.Message('To: ' + destPath);

end;

C++Script, C#Script

function LogFileParams()
{
  // Specifies the path to the file
  var sPath = "C:\\Work\\MyFile.txt";
  // Posts the file to the test log
  Log["File"](sPath, "The file has been posted to the test log");
}

function EventControl1_OnLogFile(Sender, LogParams, LogFileParams)
{
  // Obtains the full path to the posted file
  var sourPath = LogFileParams["SourceFileName"];
  Log["Message"]("From: " + sourPath);
  // Obtains the full path to the stored file
  var destPath = LogFileParams["DestFileName"];
  Log["Message"]("To: " + destPath);
}

See Also

Test Log
Log Object

Highlight search results