Open
Description
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.