The test log may store files and links to files. To post them to the log, use the
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 following code demonstrates how you can log a link to the C:\MyFile.txt file and how to save this file to the log:
Log.File("C:\\MyFile.txt", "File Message");
Log.Link("C:\\MyFile.txt", "Link Message");
Log.File("C:\\MyFile.txt", "File Message") Log.Link("C:\\MyFile.txt", "Link Message")
Log.File "C:\MyFile.txt", "File Message"
Log.Link "C:\MyFile.txt", "Link Message"
Log.File('C:\MyFile.txt', 'File Message');
Log.Link('C:\MyFile.txt', 'Link Message');
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
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
|Note:||When you use the
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
Link methods of the
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:
Link. Press Next.
On the next page specify the desired file name and other parameters of the method.
If you call the
Filemethod, then the file is specified by the FileName parameter. If you call the
Linkmethod, 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.