Class CdpDialog

java.lang.Object
io.karatelabs.driver.cdp.CdpDialog
All Implemented Interfaces:
Dialog

public class CdpDialog extends Object implements Dialog
CDP-based implementation of Dialog. Represents a JavaScript dialog (alert, confirm, prompt, or beforeunload).

Dialog types:

  • "alert" - Simple message dialog with OK button
  • "confirm" - Dialog with OK and Cancel buttons
  • "prompt" - Dialog with text input, OK and Cancel buttons
  • "beforeunload" - Dialog shown when leaving page
  • Method Details

    • getMessage

      public String getMessage()
      Description copied from interface: Dialog
      Get the dialog message.
      Specified by:
      getMessage in interface Dialog
      Returns:
      the message displayed in the dialog
    • getType

      public String getType()
      Description copied from interface: Dialog
      Get the dialog type.
      Specified by:
      getType in interface Dialog
      Returns:
      one of: "alert", "confirm", "prompt", "beforeunload"
    • getDefaultPrompt

      public String getDefaultPrompt()
      Description copied from interface: Dialog
      Get the default prompt value (for prompt dialogs).
      Specified by:
      getDefaultPrompt in interface Dialog
      Returns:
      the default value for prompt dialogs, or null for other types
    • accept

      public void accept()
      Description copied from interface: Dialog
      Accept the dialog (click OK/Yes). For prompt dialogs, this accepts with an empty string.
      Specified by:
      accept in interface Dialog
    • accept

      public void accept(String promptText)
      Description copied from interface: Dialog
      Accept the dialog with input text (for prompt dialogs).
      Specified by:
      accept in interface Dialog
      Parameters:
      promptText - the text to enter in the prompt (ignored for non-prompt dialogs)
    • dismiss

      public void dismiss()
      Description copied from interface: Dialog
      Dismiss the dialog (click Cancel/No).
      Specified by:
      dismiss in interface Dialog
    • isHandled

      public boolean isHandled()
      Description copied from interface: Dialog
      Check if this dialog has been handled.
      Specified by:
      isHandled in interface Dialog
      Returns:
      true if accept() or dismiss() has been called
    • toString

      public String toString()
      Overrides:
      toString in class Object