Log.Event Method

Applies to TestComplete 15.62, last modified on March 19, 2024

Description

The Event method posts a new event message to the test log. An event message is a message next to which TestComplete displays the Event glyph.

Declaration

Log.Event(MessageText, Details, Priority, Attr, Picture, FolderID)

MessageText [in]    Required    Variant    
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   
Picture [in]    Optional    A string, a Picture object or an object that has the Picture method which returns a Picture object    
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:

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 event message in the log. They are represented by a LogAttributes object. If this parameter is omitted, default attributes will be applied.

Picture

Specifies the image to be posted to the test log along with the message. This image will be displayed in the Picture pane of the Test Log when that message is selected. You can use one of the following values in this parameter:

  • A Picture object.
  • A window or onscreen object or the Desktop object.
  • The fully-qualified path to the image file. The following image formats are supported:
    • BMP
    • JPEG
    • PNG
    • TIFF
    • GIF
    • ICO

The format of the posted images specified by the mentioned scripting objects is controlled by the image settings of your test project. The format of images taken from existing files is not changed.

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 Event 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.EnableStackOnEvent property is True, then the test engine collects information about the execution sequence of tests that led to the call of the Log.Event method and displays this information in the Call Stack page of the test log. See Collecting Call Stack Information for Log Messages.

When an error message is posted to the log, the maximum number of event messages displayed in the test log is specified by the Store last … events project property.

When you call the Log.Event method, the test engine generates the OnLogEvent event.

Example

The code below specifies attributes for the Event message and then posts an event to the test log using these attributes.

JavaScript, JScript

function EventExample()
{
  // Specifies a short description of an event
  var Str = "The event occurred after launching the application.";
  // Specifies extended text for the event
  var ExtStr = "The event occurred after NOTEPAD.EXE was launched with the C:\Test.txt command-line parameter.";
  // Specifies the event's priority
  var Prior = pmHigher;
  //...
  // Specifies the path to an image
  var sImgPath = "C:\\Work\\MyImj.jpg";
  
  // Posts the event message to the test log
  Log.Event(Str, ExtStr, Prior, null, sImgPath);
}

Python

def EventExample():
  # Specifies a short description of an event
  Str = "The event occurred after launching the application."
  # Specifies extended text for the event
  ExtStr = "The event occurred after NOTEPAD.EXE was launched with the C:\Test.txt command-line parameter."
  # Specifies the event's priority
  Prior = pmHigher
  # ...
  # Specifies the path to an image
  sImgPath = "C:\\Work\\MyImj.jpg"
  # Posts the event message to the test log
  Log.Event(Str, ExtStr, Prior, None, sImgPath)

VBScript

Sub EventExample()

  ' Specifies a short description of an event
  Str = "The event occurred after launching the application."
  ' Specifies extended text for the event
  ExtStr = "The event occurred after NOTEPAD.EXE was launched with the C:\Test.txt command-line parameter."
  ' Specifies the event's priority
  Prior = pmHigher
  '...
  ' Specifies the path to an image
  sImgPath = "C:\Work\MyImj.jpg"
  
  ' Posts the event message to the test log
  Call Log.Event(Str, ExtStr, Prior, , sImgPath)

End Sub

DelphiScript

function EventExample;
var Str, ExtStr, Prior, sImgPath;
begin

  // Specifies a short description of an event
  Str := 'The event occurred after launching the application.';
  // Specifies extended text for the event
  ExtStr := 'The event occurred after NOTEPAD.EXE was launched with the C:\Test.txt command-line parameter.';
  // Specifies the event's priority
  Prior := pmHigher;
  //...
  // Specifies the path to an image
  sImgPath := 'C:\Work\MyImj.jpg';
  
  // Posts the event message to the test log
  Log.Event(Str, ExtStr, Prior, nil, sImgPath);

end;

C++Script, C#Script

function EventExample()
{
  // Specifies a short description of an event
  var Str = "The event occurred after launching the application.";
  // Specifies extended text for the event
  var ExtStr = "The event occurred after NOTEPAD.EXE was launched with the C:\Test.txt command-line parameter.";
  // Specifies the event's priority
  var Prior = pmHigher;
  //...
  // Specifies the path to an image
  var sImgPath = "C:\\Work\\MyImj.jpg";
  
  // Posts the event message to the test log
  Log["Event"](Str, ExtStr, Prior, null, sImgPath);
}

See Also

Test Results
Posting Messages to the Log
EvnCount Property
Error Method
Message Method
Warning Method
Checkpoint Method
Picture Method
File Method
Link Method
OnLogEvent Event
LogAttributes Object

Highlight search results