Log.Picture Method

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

The Picture method posts an image to the test log as an attachment to an informative message ( ) and copies the image to the folder where results are kept. TestComplete displays the icon in the Has Picture column of the Test Log panel for the messages that have images associated with them.

Declaration

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

Picture [in]    Required    A Picture object or an object that has the Picture method which returns a Picture object    
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 String

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Picture

The Picture object that represents the image to be posted to the test log along with the message. Alternatively, this can be an object that has the Picture method which returns the desired Picture object. This image will be displayed in the Picture pane of the Test Log when the message is selected in the Test Log. For information on how to specify the format of log images, see Specifying Log Images Format.

Note: Unlike TestComplete 3, TestComplete 4 and later does not allow you to specify the image’s file name in the Picture parameter. TestComplete only requires the Picture object. To workaround the problem, you can create a new Picture object using the Utils.Picture method, load the desired image to it and then post the Picture object to the log (see the example below).

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 picture 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 Picture 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

The full path to the posted image file.

Remarks

Example

The code below loads an image from a file using the Utils.Picture method and then posts this image to the test log.

JavaScript, JScript

function PostingPictures()
{
  var PicObj = Utils.Picture;
  // Loads an image from a file
  PicObj.LoadFromFile("C:\\MyPicture.bmp");
  // Saves this image to the test log
  Log.Picture(PicObj);
}

Python

def PostingPictures():
  PicObj = Utils.Picture
  # Loads an image from a file
  PicObj.LoadFromFile("C:\\Work\\MyPicture.bmp")
  # Saves this image to the test log
  Log.Picture(PicObj)

VBScript

Sub PostingPictures()
  Set PicObj = Utils.Picture
  ' Loads an image from a file
  PicObj.LoadFromFile("C:\MyPicture.bmp")
  ' Saves this image to the test log
  Log.Picture(PicObj)
End Sub

DelphiScript

function PostingPictures;
var PicObj;
begin
  PicObj := Utils.Picture;
  // Loads an image from a file
  PicObj.LoadFromFile('C:\MyPicture.bmp');
  // Saves this image to the test log
  Log.Picture(PicObj);
end;

C++Script, C#Script

function PostingPictures()
{
  var PicObj = Utils["Picture"];
  // Loads an image from a file
  PicObj["LoadFromFile"]("C:\\MyPicture.bmp");
  // Saves this image to the test log
  Log["Picture"](PicObj);
}

See Also

Test Results
Posting Images to the Log
Specifying Log Images Format
ImgCount Property
Error Method
Message Method
Warning Method
Event Method
Checkpoint Method
File Method
Link Method
LogAttributes Object
OnLogPicture Event

Highlight search results