Posting Files to the Log

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

The test log may store files and links to files. To post them to the log, use the File and Link methods of the Log object. Both methods post messages of the informative type to the log. The name of the file posted along with the message is shown in the Link column of the test log. The difference between these methods is that File copies the specified file to the log folder (see Test Results), while Link posts a link to a file.

The File and Link methods have parameters that let you specify extended message text, priority and other message attributes. For more information about the parameters, see the method’s descriptions.

The following code demonstrates how you can log a link to the C:\MyFile.txt file and how to save this file to the log:

JavaScript, JScript

Log.File("C:\\MyFile.txt", "File Message");
Log.Link("C:\\MyFile.txt", "Link Message");

Python

Log.File("C:\\MyFile.txt", "File Message")
Log.Link("C:\\MyFile.txt", "Link Message")

VBScript

Log.File "C:\MyFile.txt", "File Message"
Log.Link "C:\MyFile.txt", "Link Message"

DelphiScript

Log.File('C:\MyFile.txt', 'File Message');
Log.Link('C:\MyFile.txt', 'Link Message');

C++Script, C#Script

Log["File"]("C:\\MyFile.txt", "File Message");
Log["Link"]("C:\\MyFile.txt", "Link Message");

After executing this code, the script log will include two messages of the file type. TestComplete displays these messages as informative messages () with a link to the posted files in the Link column:

  • One of these messages will show the full file name (C:\MyFile.txt) in the Link column. This message was posted by the Link method.

  • The Link column of another message will show the file name in the format FileN.txt; e.g.: File0.txt. This message was generated by the File method.

Note: When you use the Log.Link method to post links to web resources of the HTTP protocol, always specify the protocol name in the resource’s address, for example, http://www.smartbear.com. Otherwise, when you export the test log, the link will not be exported. Also, note that exporting links to resources of protocols other than the HTTP protocol is not supported. For more information, see Exporting Test Results.

To post files or file links to the log from keyword tests, you can use the Call Object Method or Run Code Snippet operation. Both operations belong to the Test Actions category. You use them to call the File or Link methods of the Log object.

Using the Call Object Method operation is simple:

  • Add the operation to your keyword test. TestComplete will display the Operation Parameters wizard.

  • On the first page of the wizard, type Log to specify the object, whose method will be called, and press Next.

  • On the next page, choose the method to be called. Choose the desired method: File or Link. Press Next.

  • On the next page specify the desired file name and other parameters of the method.
    If you call the File method, then the file is specified by the FileName parameter. If you call the Link method, then the desired file is specified by the Link parameter.

  • Click Finish to add the operation to the test.

To post a message with the Run Code Snippet operation, add this operation to the test and then type the script code that calls the desired method, into the Operation Parameters wizard. You can use the same code that is used in the examples above.

See Also

Posting Messages, Images and Files to the Log
File Method
Link Method
Call Object Method Operation
Run Code Snippet Operation

Highlight search results