Class ConsoleMessages
java.lang.Object
net.serenitybdd.screenplay.playwright.questions.ConsoleMessages
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 Summary
Modifier and TypeMethodDescriptionall()Get all captured console message texts.static net.serenitybdd.screenplay.Question<List<CaptureConsoleMessages.CapturedConsoleMessage>>Get all captured console messages as full objects.containing(String substring) Get messages containing the specified text.static net.serenitybdd.screenplay.Question<Integer>count()Get the count of captured messages.static net.serenitybdd.screenplay.Question<Integer>Get the count of error messages.errors()Get all captured error message texts.info()Get all captured info message texts.logs()Get all captured log message texts.warnings()Get all captured warning message texts.
-
Method Details
-
all
Get all captured console message texts. -
errors
Get all captured error message texts. -
warnings
Get all captured warning message texts. -
logs
Get all captured log message texts. -
info
Get all captured info message texts. -
containing
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
Get the count of captured messages. -
errorCount
Get the count of error messages.
-