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

public class HandleDialog extends Object implements net.serenitybdd.screenplay.Performable
Handle JavaScript dialogs (alert, confirm, prompt).

This interaction sets up a dialog handler that will be triggered when the next dialog appears. Must be called BEFORE the action that triggers the dialog.

Sample usage:

     actor.attemptsTo(
         HandleDialog.byAccepting(),
         Click.on("#trigger-alert")
     );

     actor.attemptsTo(
         HandleDialog.byDismissing(),
         Click.on("#trigger-confirm")
     );

     actor.attemptsTo(
         HandleDialog.byEntering("some text"),
         Click.on("#trigger-prompt")
     );
 
  • Method Details

    • byAccepting

      public static HandleDialog byAccepting()
      Accept the next dialog (clicks OK/Accept).
    • byDismissing

      public static HandleDialog byDismissing()
      Dismiss the next dialog (clicks Cancel/Dismiss).
    • byEntering

      public static HandleDialog byEntering(String text)
      Enter text into the next prompt dialog and accept it.
    • performAs

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

      public String toString()
      Overrides:
      toString in class Object