SourceFileName Property

Applies to TestComplete 15.63, last modified on April 23, 2024

Description

The SourceFileName property specifies the full path to the referenced file (image file). If the Log.Picture method used a screenshot, this property returns an empty string.

Declaration

LogFileParamsObj.SourceFileName

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

Applies To

The property is applied to the following object:

Property Value

The full path to the referenced file (image file).

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
Log.Picture

Highlight search results