Description
The Link
method posts a reference to a file or to any other source (say, a Web page) to the test log as an attachment to an informative message. The link to the file is displayed in the Link column of the Test Log panel.
Declaration
Log.Link(Link, MessageText, Details, Priority, Attr, FolderID)
Link | [in] | Required | String | |
MessageText | [in] | Optional | Variant | Default value: Empty string |
Details | [in] | Optional | Variant | Default value: Empty string |
Priority | [in] | Optional | Integer | Default value: pmNormal |
Attr | [in] | Optional | A LogAttributes object |
Default value: Default attributes |
FolderID | [in] | Optional | Integer | Default value: -1 |
Result | None |
Applies To
The method is applied to the following object:
Parameters
The method has the following parameters:
Link
The reference string to be posted to the test log. This text will be added to the Link column of the Test Log.
Note: | You can specify the exact text you want to post to the test log or you can specify the name of an environment variable that stores this text. For this purpose, use the Log.Link("%ProgramFiles%\SmartBear\TestComplete 14\Bin\TestComplete.exe", "Test Link", , , , ) syntax. |
MessageText
Message text. This text will be added to the Message column of the Test Log. MessageText can hold data of any OLE-compatible type. If it cannot be converted to text, its value is ignored.
The parameter does not support multiline text, that is, you cannot post multiline messages to the Message column. To post multiline text to your test log, use the AdditionalInformation parameter.Details
Additional text to be displayed in the Details pane of the Test Log. Details can hold data of any type compatible with OLE. If it cannot be converted to text, its value is ignored.
The Details parameter can also hold HTML code. The test engine will compile the HTML page and display it in the Details pane. For more information, see Posting Messages to the Log.
Priority
Message priority. You can use any integer number or any of the following constants:
Constant | Value | Description |
---|---|---|
pmLowest |
100 | The lowest priority of the message. |
pmLower |
200 | The message priority which is lower than normal. |
pmNormal |
300 | The normal (default) priority of the message. |
pmHigher |
400 | The message priority which is higher than normal. |
pmHighest |
500 | The highest priority of the message. |
Attr
The font and color settings that will be applied to the newly created link message in the log. They are represented by a LogAttributes
object. If this parameter is omitted, default attributes will be applied.
FolderID
Identifier of the test log’s folder to which the message will be posted. To get this identifier, use the CreateFolder
or AppendFolder
method. If this parameter refers to a non-existent folder, is omitted or is set to -1 (the default value), the Link
method will either post the message to the default folder of the test log or append it to the test log outside of any folder (if the default folder is not set). The default folder is the folder that is currently at the top of the folder stack, which is populated during the script run. To push a folder to or pop it out of this stack, use the PushLogFolder
or the PopLogFolder
method correspondingly.
Result Value
None.
Remarks
If the Log.CallStackSettings.EnableStackOnLink
or Log.CallStackSettings.EnableStackOnFile
property is True, then the test engine collects information about the execution sequence of tests that led to the call of the Log.Link
method and displays this information in the Call Stack page of the test log. See Collecting Call Stack Information for Log Messages.
When you call the Log.Link
method, the test engine generates the OnLogLink
event.
When you post a link to a web page, specify the page's full URL, including the HTTP protocol, in the Link parameter, for example, http://www.smartbear.com. Otherwise, if you export the test log, the link can be exported incorrectly and the Link column of the corresponding link message will be empty in the exported test log.
Note: | Links to resources of any protocol (for example, HTTPS, MAILTO and so on) can be posted to the test log. However, you can export links to resources of the HTTP protocol. Links to resources of other protocols will not be exported and the Link column of the corresponding link messages will be empty in the exported log. |
Example
This code posts various kinds of links to the test log.
JavaScript, JScript
function Test()
{
Log.Link("http://smartbear.com", "A web link");
Log.Link("C:\\Windows\\notepad.exe", "A file link");
Log.Link("ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt", "An FTP link");
Log.Link("mailto:[email protected]", "A mailto link");
}
Python
def Test():
Log.Link("http://smartbear.com", "A web link")
Log.Link("C:\\Windows\\notepad.exe", "A file link")
Log.Link("ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt", "An FTP link")
Log.Link("mailto:[email protected]", "A mailto link")
VBScript
Sub Test
Call Log.Link("http://smartbear.com", "A web link")
Call Log.Link("C:\Windows\notepad.exe", "A file link")
Call Log.Link("ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt", "An FTP link")
Call Log.Link("mailto:[email protected]", "A mailto link")
End Sub
DelphiScript
procedure Test;
begin
Log.Link('http://smartbear.com', 'A web link');
Log.Link('C:\Windows\notepad.exe', 'A file link');
Log.Link('ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt', 'An FTP link');
Log.Link('mailto:[email protected]', 'A mailto link');
end;
C++Script, C#Script
function Test()
{
Log.Link("http://smartbear.com", "A web link");
Log.Link("C:\\Windows\\notepad.exe", "A file link");
Log.Link("ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt", "An FTP link");
Log.Link("mailto:[email protected]", "A mailto link");
}
See Also
Test Results
Posting Messages, Images and Files to the Log
LinkCount Property
Error Method
Message Method
Warning Method
Event Method
Picture Method
File Method
OnLogLink Event
LogAttributes Object
Exporting Test Results