Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HoaiLinh0908 opened this issue Apr 4, 2025 · 1 comment
Labels
A-needs-triaging A Selenium member will evaluate this soon! B-devtools Includes everything BiDi or Chrome DevTools related C-java Java Bindings I-enhancement Something could be better

Comments

@HoaiLinh0908
Copy link

HoaiLinh0908 commented Apr 4, 2025

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.

@HoaiLinh0908 HoaiLinh0908 added A-needs-triaging A Selenium member will evaluate this soon! I-enhancement Something could be better labels Apr 4, 2025
@titusfortner
Copy link
Member

@HoaiLinh0908, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then J-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@github-actions github-actions bot added B-devtools Includes everything BiDi or Chrome DevTools related C-java Java Bindings labels Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-needs-triaging A Selenium member will evaluate this soon! B-devtools Includes everything BiDi or Chrome DevTools related C-java Java Bindings I-enhancement Something could be better
Projects
None yet
Development

No branches or pull requests

2 participants