java.lang.Object
net.serenitybdd.screenplay.playwright.interactions.CaptureConsoleMessages
All Implemented Interfaces:
net.serenitybdd.core.SkipNested, net.serenitybdd.screenplay.Performable

public class CaptureConsoleMessages extends Object implements net.serenitybdd.screenplay.Performable
Start capturing browser console messages for later analysis.

Console messages include logs, warnings, errors, and other output from JavaScript running in the browser.

Sample usage:

     // Start capturing all console messages
     actor.attemptsTo(CaptureConsoleMessages.duringTest());

     // ... perform actions that generate console output ...

     // Query captured messages
     List<String> errors = actor.asksFor(ConsoleMessages.errors());
     List<String> warnings = actor.asksFor(ConsoleMessages.warnings());
     List<String> allMessages = actor.asksFor(ConsoleMessages.all());

     // Clear captured messages
     actor.attemptsTo(CaptureConsoleMessages.clear());
 
See Also:
  • Method Details

    • duringTest

      public static CaptureConsoleMessages duringTest()
      Start capturing console messages during the test. Messages will be stored and can be queried using ConsoleMessages questions.
    • clear

      public static CaptureConsoleMessages clear()
      Clear all previously captured console messages.
    • performAs

      public <T extends net.serenitybdd.screenplay.Actor> void performAs(T actor)
      Specified by:
      performAs in interface net.serenitybdd.screenplay.Performable
    • getConsoleMessagesKey

      public static String getConsoleMessagesKey()
      Get the key used to store console messages in actor's memory.