LogAttributes Object

Applies to TestComplete 14.71, last modified on April 22, 2021

Description

The LogAttributes object is used to store font and color settings that can be applied to messages and folders in the Test Log. This object is passed as the Attr parameter to the Log.CreateFolder, Log.AppendFolder, Log.Error, Log.Warning, Log.Message, Log.Event, Log.Picture, Log.File and Log.Link methods.

To create a LogAttributes object, call the CreateNewAttributes method of the Log object. Once the LogAttributes object is created, its properties are populated with default font and color settings accordingly.

Members

Example

The following code demonstrates how to use the LogAttributes object to specify custom attributes for a folder name and message text. To denote the desired font and background colors for the folder name, we use color constants. For more information about them, see Working With Colors.

JavaScript, JScript

function LogAttributes()
{
  // Specifies new attributes
  var attr1 = Log.CreateNewAttributes();
  var attr2 = Log.CreateNewAttributes();
  attr1.BackColor = clPurple;
  attr1.FontColor = clYellow;
  attr2.Bold = true;
  attr2.Italic = true;
  // ...
  // Applies attributes to a folder name and a message
  Log.AppendFolder("My Folder", "", pmNormal, attr1);
  Log.Message("My Text", "", pmNormal, attr2);
}

Python

def LogAttributes():
  # Specifies new attributes
  attr1 = Log.CreateNewAttributes()
  attr2 = Log.CreateNewAttributes()
  attr1.BackColor = clPurple
  attr1.FontColor = clYellow
  attr2.Bold = True
  attr2.Italic = True
  # ...
  # Applies attributes to a folder name and a message
  Log.AppendFolder("My Folder", "", pmNormal, attr1)
  Log.Message("My Text", "", pmNormal, attr2)

VBScript

Sub LogAttributes()
  ' Specifies new attributes
  Set attr1 = Log.CreateNewAttributes
  Set attr2 = Log.CreateNewAttributes
  attr1.BackColor = clPurple
  attr1.FontColor = clYellow
  attr2.Bold = true
  attr2.Italic = true
  ' ...
  ' Applies attributes to a folder name and a message
  Call Log.AppendFolder("My Folder", "", pmNormal, attr1)
  Call Log.Message("My Text", "", pmNormal, attr2)
End Sub

DelphiScript

function LogAttributes;
var attr1, attr2;
begin
  // Specifies new attributes
  attr1 := Log.CreateNewAttributes;
  attr2 := Log.CreateNewAttributes;
  attr1.BackColor := clPurple;
  attr1.FontColor := clYellow;
  attr2.Bold := true;
  attr2.Italic := true;
  // ...
  // Applies attributes to a folder name and a message
  Log.AppendFolder('My Folder', '', pmNormal, attr1);
  Log.Message('My Text', '', pmNormal, attr2);
end;

C++Script, C#Script

function LogAttributes()
{
  // Specifies new attributes
  var attr1 = Log["CreateNewAttributes"]();
  var attr2 = Log["CreateNewAttributes"]();
  attr1["BackColor"] = clPurple;
  attr1["FontColor"] = clYellow;
  attr2["Bold"] = true;
  attr2["Italic"] = true;
  // ...
  // Applies attributes to a folder name and a message
  Log["AppendFolder"]("My Folder", "", pmNormal, attr1);
  Log["Message"]("My Text", "", pmNormal, attr2);
}

See Also

Test Log
Log Object

Highlight search results