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

public class CheckConsole extends Object implements net.serenitybdd.screenplay.Performable
Check for console errors and warnings, optionally failing the test if any are found.

This interaction provides a convenient way to verify that no JavaScript errors or warnings occurred during a test, which is a common quality check for web applications.

Sample usage:

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

     // ... perform actions ...

     // Fail the test if any console errors occurred
     actor.attemptsTo(CheckConsole.forErrors());

     // Fail if any errors OR warnings occurred
     actor.attemptsTo(CheckConsole.forErrorsAndWarnings());

     // Just report to Serenity without failing the test
     actor.attemptsTo(CheckConsole.forErrors().andReportOnly());
 
See Also:
  • Method Details

    • forErrors

      public static CheckConsole forErrors()
      Check for console errors. Fails the test if any errors are found.
    • forWarnings

      public static CheckConsole forWarnings()
      Check for console warnings. Fails the test if any warnings are found.
    • forErrorsAndWarnings

      public static CheckConsole forErrorsAndWarnings()
      Check for both console errors and warnings. Fails the test if any are found.
    • andReportOnly

      public CheckConsole andReportOnly()
      Report any found messages to Serenity but don't fail the test. Use this when you want to document console output without enforcing it.
    • performAs

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

      public String getMessageTypeDescription_forStep()