Log.AppendFolder Method

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

Description

The AppendFolder method creates a new folder in the test log and activates it. Once activated, TestComplete can send all posted messages to this folder. The folder can hold messages of different types (they are posted by the Log.Error, Log.Warning, Log.Message, Log.Event, Log.Picture, Log.File and Log.Link methods) as well as other folders.

Declaration

Log.AppendFolder(MessageTextAdditionalInformationPriorityAttrOwnerFolderID)

MessageText [in]    Required    Variant    
AdditionalInformation [in]    Optional    Variant Default value: Empty string   
Priority [in]    Optional    Integer Default value: pmNormal   
Attr [in]    Optional    A LogAttributes object Default value: Default attributes   
OwnerFolderID [in]    Optional    Integer Default value: -1   
Result Integer

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

MessageText

Folder caption. This text will be added to the Message column of the Test Log. Str can hold data of any OLE-compatible type. If it cannot be converted to text, its value is ignored.

AdditionalInformation

Additional text to be displayed in the Details panel of the Test Log. StrEx can hold data of any type compatible with OLE. If it cannot be converted to text, its value is ignored.

Priority

Folder priority. You can use any integer number or any of the following constants:

Constant Value Description
pmLowest 100 The lowest priority of the folder.
pmLower 200 The folder priority which is lower than normal.
pmNormal 300 The normal (default) priority of the folder.
pmHigher 400 The folder priority which is higher than normal.
pmHighest 500 The highest priority of the folder.

Attr

The font and color settings that will be applied to the newly created folder in the log. They are represented by a LogAttributes object. If this parameter is omitted, default attributes will be applied.

OwnerFolderID

Identifier of the test log’s folder where a new folder will be created as a subfolder. To get this identifier, use the CreateFolder or AppendFolder method (they will create the parent folder). If this parameter refers to a non-existent folder, is omitted or is set to -1 (the default value), the AppendFolder method will either create the folder in the default folder of the test log or append it to the test log outside of any other 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

An integer value that represents the identifier of the newly created folder in the test log.

Remarks

The AppendFolder method is similar to the CreateFolder method. The difference between them is that CreateFolder just creates a new folder, while AppendFolder creates a folder and activates it, so you do not need to call PushLogFolder after AppendFolder.

You can prevent TestComplete from creating extra folders by using the LogParams.Locked method. There is no need to pop folders that were not created, or those folders that were not pushed.

Example

The following example creates a structure of folders and messages in the test log. This structure is shown in the image below.

JavaScript, JScript

var FolderID = new Array(3);
Log.Message("Message1");
Log.Error("Error1");
for (var i = 0; i < 3; i++)
{
  FolderID[i] = Log.CreateFolder("Folder" + i);
  Log.PushLogFolder(FolderID[i]);
  Log.Warning("Warning" + i);
}
Log.Event("Event1");
Log.PopLogFolder();
Log.CreateFolder("Folder4");
Log.Link("www.oursite.com");
Log.PopLogFolder();
Log.Message("Message2");
Log.CreateFolder("Folder5", "", pmHigher, Log.CreateNewAttributes(), FolderID[2]);

Python

FolderID = []
Log.Message("Message1")
Log.Error("Error1")
for i in range(0, 3):
  FolderID.append(Log.CreateFolder("Folder" + str(i)))
  Log.PushLogFolder(FolderID[i])
  Log.Warning("Warning" + str(i))
Log.Event("Event1")
Log.PopLogFolder()
Log.CreateFolder("Folder4")
Log.Link("www.oursite.com")
Log.PopLogFolder()
Log.Message("Message2")
Log.CreateFolder("Folder5", "", pmHigher, Log.CreateNewAttributes(), FolderID[2])

VBScript

Log.Message("Message1")
Log.Error("Error1")
Dim FolderID(2)
For i = 0 To 2
  FolderID(i) = Log.CreateFolder("Folder" & i)
  Log.PushLogFolder(FolderID(i))
  Log.Warning("Warning" & i)
Next
Log.Event("Event1")
Log.PopLogFolder
Log.CreateFolder("Folder4")
Log.Link("www.oursite.com")
Log.PopLogFolder
Log.Message("Message2")
Call Log.CreateFolder("Folder5", , , , FolderID(2))

DelphiScript

var
  i;
  FolderID : array[0..2];
begin
  Log.Message('Message1');
  Log.Error('Error1');
  for i := 0 to 2 do
  begin
    FolderID[i] := Log.CreateFolder('Folder' + aqConvert.VarToStr(i));
    Log.PushLogFolder(FolderID[i]);
    Log.Warning('Warning' + aqConvert.VarToStr(i));
  end;
  Log.Event('Event1');
  Log.PopLogFolder;
  Log.CreateFolder('Folder4');
  Log.Link('www.oursite.com');
  Log.PopLogFolder;
  Log.Message('Message2');
  Log.CreateFolder('Folder5', '', pmHigher, Log.CreateNewAttributes, FolderID[2]);
end;

C++Script, C#Script

var FolderID = new Array(3);
Log["Message"]("Message1");
Log["Error"]("Error1");
for (var i = 0; i < 3; i++){
  FolderID[i] = Log["CreateFolder"]("Folder" + i);
  Log["PushLogFolder"](FolderID[i]);
  Log["Warning"]("Warning" + i);
}
Log["Event"]("Event1");
Log["PopLogFolder"]();
Log["CreateFolder"]("Folder4");
Log["Link"]("www.oursite.com");
Log["PopLogFolder"]();
Log["Message"]("Message2");
Log["CreateFolder"]("Folder5", "", pmHigher, Log["CreateNewAttributes"](), FolderID[2]);

If you need to activate a log folder right after creating it, you can use the AppendFolder method instead of the combination of CreateFolder and PushLogFolder. The following code snippet shows how this can be done in the example above:

JavaScript, JScript

FolderID[i] = Log.CreateFolder("Folder" + i);
Log.PushLogFolder(FolderID[i]);
// is equal to
FolderID[i] = Log.AppendFolder("Folder" + i);

Python

FolderID.append(Log.CreateFolder("Folder" + str(i)))
Log.PushLogFolder(FolderID[i])
# is equal to
FolderID.append(Log.AppendFolder("Folder" + str(i)))

VBScript

FolderID(i) = Log.CreateFolder("Folder" & i)
Log.PushLogFolder(FolderID(i))
' is equal to
FolderID(i) = Log.AppendFolder("Folder" & i)

DelphiScript

FolderID[i] := Log.CreateFolder('Folder' + aqConvert.VarToStr(i));
Log.PushLogFolder(FolderID[i]);
// is equal to
FolderID[i] := Log.AppendFolder("Folder" + aqConvert.VarToStr(i));

C++Script, C#Script

FolderID[i] = Log["CreateFolder"]("Folder" + i);
Log["PushLogFolder"](FolderID[i]);
// is equal to
FolderID[i] = Log["AppendFolder"]("Folder" + i);

See Also

Test Results
Using Folders
CreateFolder Method
PushLogFolder Method
PopLogFolder Method
FolderCount Method
Error Method
Warning Method
Message Method
Event Method
Picture Method
File Method
Link Method
CreateNewAttributes Method
LogAttributes Object

Highlight search results