Log.PushLogFolder Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The PushLogFolder method adds the specified folder to the folder stack and makes it the top folder of the stack. The top folder is the default one. This means that the Log.CreateFolder method will create new folders in it and all the messages posted by the Log.Error, Log.Warning, Log.Message, Log.Event, Log.Picture, Log.File and Log.Link methods will be placed in that folder. To pop the top folder out of the folder stack, call the PopLogFolder method. Upon doing this, the folder that follows the popped out folder will become the top folder of the stack.

Declaration

Log.PushLogFolder(FolderID)

FolderID [in]    Required    Integer    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

FolderID

Identifier of the existing test log folder that you want to push to the folder stack. To get the folder’s identifier, use the CreateFolder method.

Result Value

None.

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
AppendFolder Method
PopLogFolder Method
Error Method
Warning Method
Message Method
Event Method
Picture Method
File Method
Link Method

Highlight search results