Skip to content

[🚀 Feature]: Can we have a better way to handle dialog (alert, prompt) when enabling WebDriver BiDi #15573

Open
@HoaiLinh0908

Description

@HoaiLinh0908

Description

I'm currently enabling WebDriver BiDi because of its advantages, but things get complicated when it comes to dialog (like alert, model, and prompt). I have to add a lot of code compared to the Legacy protocol to work with alert
WebDriver BiDi:

  DevTools devTools = ((ChromeDriver) webDriver).getDevTools();
  devTools.createSession();

  // Listen for JavaScript dialogs (alerts, confirms, prompts)
  devTools.send(Page.enable());
  devTools.addListener(Page.javascriptDialogOpening(), dialog -> {
    System.out.println("Alert Text: " + dialog.getMessage());
    devTools.send(Page.handleJavaScriptDialog(true, null)); // Accept the alert
  });

Legacy:

webDriver.switchTo().alert();

It would be nice to have a more user-friendly way to handle alerts, as it is heavily used in almost every project.

Have you considered any alternatives or workarounds?

I'm currently turning off BiDi on tests that contain alerts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!B-devtoolsIncludes everything BiDi or Chrome DevTools relatedC-javaJava BindingsI-enhancementSomething could be better

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions