Organizing Log Messages

Applies to TestLeft 4.72, last modified on December 21, 2020

By default, the test log has a plain structure. However, you can organize related messages into folders within the test log. For instance, you can divide a test into several logical parts and post messages of each part to a separate folder.

To create a log folder –

.NET: Call the IDriver.Log.OpenFolder method.

Java: Call the driver.getLog().openFolder method.

The method creates a folder in the test log and activates it. TestLeft will post all subsequent log messages to the folder.

To close the folder –

.NET: Call the IDriver.Log.CloseFolder method.

Java: Call the driver.getLog.closeFolder method.

The method closes the currently active log folder and makes the parent of that folder active. TestLeft will post all subsequent log messages to the parent folder.

C#

using SmartBear.TestLeft;


public void Test()
{

  Driver.Log.Message("Message A");

  // Creates a folder and activates it
  Driver.Log.OpenFolder("Folder 1");

  // Posts messages to the new folder Folder 1
  Driver.Log.Message("Message B");

  // Creates a new folder and activates it
  Driver.Log.OpenFolder("Folder 2");

  // Posts messages to the new folder Folder 2
  Driver.Log.Message("Message C");
  Driver.Log.Message("Message D");

  // Closes Folder 2 and activates Folder 1
  Driver.Log.CloseFolder();

  // Posts messages to Folder 1
  Driver.Log.Message("Message E");

  // Closes Folder 1
  Driver.Log.CloseFolder();

  Driver.Log.Message("Message F");

}

Visual Basic .NET

Imports SmartBear.TestLeft

Public Sub Test()

  Driver.Log.Message("Message A")
  ' Creates a folder and activates it
  Driver.Log.OpenFolder("Folder 1")

  ' Posts messages to the new folder Folder 1
  Driver.Log.Message("Message B")

  ' Creates a new folder and activates it
  Driver.Log.OpenFolder("Folder 2")

  ' Posts messages to the new folder Folder 2
  Driver.Log.Message("Message C")
  Driver.Log.Message("Message D")

  ' Closes Folder 2 and activates Folder 1
  Driver.Log.CloseFolder()

  ' Posts messages to Folder 1
  Driver.Log.Message("Message E")

  ' Closes Folder 1
  Driver.Log.CloseFolder()

  Driver.Log.Message("Message F")

End Sub

Java

import com.smartbear.testleft.*;

public void Test() throws Exception{

  driver.getLog().message("Message A");
  // Creates a folder and activates it
  driver.getLog().openFolder("Folder 1");

  // Posts messages to the new folder Folder 1
  driver.getLog().message("Message B");

  // Creates a new folder and activates it
  driver.getLog().openFolder("Folder 2");

  // Posts messages to the new folder Folder 2
  driver.getLog().message("Message C");
  driver.getLog().message("Message D");

  // Closes Folder 2 and activates Folder 1
  driver.getLog().closeFolder();

  // Posts messages to Folder 1
  driver.getLog().message("Message E");

  // Closes Folder 1
  driver.getLog().closeFolder();

  driver.getLog().message("Message F");

}

The example above sets the following hierarchy of log messages:

Message hierarchy

See Also

Working With TestLeft Test Logs
About Driver Objects

Highlight search results