java.lang.Object
net.serenitybdd.screenplay.playwright.questions.ConsoleMessages

public class ConsoleMessages extends Object
Query captured browser console messages.

Before using these questions, you must start capturing console messages using CaptureConsoleMessages.duringTest().

Sample usage:

     // Start capturing
     actor.attemptsTo(CaptureConsoleMessages.duringTest());

     // ... perform actions ...

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

     // Check for specific content
     List<String> apiErrors = actor.asksFor(ConsoleMessages.containing("API error"));

     // Get full message objects for detailed analysis
     List<CapturedConsoleMessage> messages = actor.asksFor(ConsoleMessages.allCaptured());
 
See Also:
  • Method Details

    • all

      public static net.serenitybdd.screenplay.Question<List<String>> all()
      Get all captured console message texts.
    • errors

      public static net.serenitybdd.screenplay.Question<List<String>> errors()
      Get all captured error message texts.
    • warnings

      public static net.serenitybdd.screenplay.Question<List<String>> warnings()
      Get all captured warning message texts.
    • logs

      public static net.serenitybdd.screenplay.Question<List<String>> logs()
      Get all captured log message texts.
    • info

      public static net.serenitybdd.screenplay.Question<List<String>> info()
      Get all captured info message texts.
    • containing

      public static net.serenitybdd.screenplay.Question<List<String>> containing(String substring)
      Get messages containing the specified text.
      Parameters:
      substring - The text to search for
    • allCaptured

      public static net.serenitybdd.screenplay.Question<List<CaptureConsoleMessages.CapturedConsoleMessage>> allCaptured()
      Get all captured console messages as full objects. Useful for accessing message type, location, and other details.
    • count

      public static net.serenitybdd.screenplay.Question<Integer> count()
      Get the count of captured messages.
    • errorCount

      public static net.serenitybdd.screenplay.Question<Integer> errorCount()
      Get the count of error messages.