Skip to content

[🐛 Bug]: JavaScript alerts/prompts not displayed or handled when using Chrome with BiDi mode (Selenium 4.38 & .Net v4.8) #16547

@SKumar-777

Description

@SKumar-777

Description

When launching Chrome with BiDi enabled using UseWebSocketUrl and --remote-debugging-pipe, JavaScript alert dialogs (e.g., alert(), confirm(), prompt()) are suppressed. The same site displays the dialogs correctly when launched manually or when BiDi mode is disabled.

This issue prevents automation of any site logic that depends on JavaScript dialogs. Is that BiDi mode intentionally suppresses JavaScript dialogs?, If so, this makes it currently impossible to migrate existing Selenium suites to BiDi if they rely on standard alert handling, creating a functional gap between BiDi and legacy WebDriver capabilities.

Note: BiDi mode was enabled intentionally to support loading my Chrome extension in the automated chrome session (v142).

ChromeOptions options = new ChromeOptions();
//Using Bidi to load my chrome exetension in chrome browser v142.
options.UseWebSocketUrl = true;//To enable BiDi protocol for communication.
options.AddArgument("--remote-debugging-pipe");
options.AddArgument("--enable-unsafe-extension-debugging");
options.AddArguments("--no-sandbox");
driver = new RemoteWebDriver(new Uri("http://localhost:xxxx"), options);
//Extension load code ....
driver.Navigate().GoToUrl("https://demo.automationtesting.in/Alerts.html");
// Clicks the button to display a JavaScript alert, but the alert is not displayed (suppressed in BiDi mode).
try
{
IAlert alert = driver.SwitchTo().Alert();
Console.WriteLine("Alert text: " + alert.Text);
alert.SendKeys("Selenium BiDi Test");
alert.Accept();
}
catch (NoAlertPresentException)
{
Console.WriteLine("No alert displayed when using BiDi mode.");
}

Reproducible Code

ChromeOptions options = new ChromeOptions();
//Using Bidi to load my chrome exetension in chrome browser v142.
options.UseWebSocketUrl = true;//To enable BiDi protocol for communication.
options.AddArgument("--remote-debugging-pipe");
options.AddArgument("--enable-unsafe-extension-debugging");
options.AddArguments("--no-sandbox");
driver = new RemoteWebDriver(new Uri("http://localhost:xxxx"), options);
//Extension load code ....
driver.Navigate().GoToUrl("https://demo.automationtesting.in/Alerts.html");
// Clicks the button to display a JavaScript alert, but the alert is not displayed (suppressed in BiDi mode).
try
{
    IAlert alert = driver.SwitchTo().Alert();
    Console.WriteLine("Alert text: " + alert.Text);
    alert.SendKeys("Selenium BiDi Test");
    alert.Accept();
}
catch (NoAlertPresentException)
{
    Console.WriteLine("No alert displayed when using BiDi mode.");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-dotnet.NET BindingsI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions