-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Closed
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!I-defectSomething is not working as intendedSomething is not working as intended
Description
What happened?
If disable BiDi, both Chrome and Firefox are fine to trigger alert.
If enableBiDi, Selenium can't trigger the Alert in Chrome with Java 4.24.0 , but work with Firefox.
more detail can be refer to below code.
How can we reproduce the issue?
package cn.ianzhang;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
public class AlertTest {
@Test
void noBidiChromeTest() {
ChromeOptions options = new ChromeOptions();
WebDriver driver = new ChromeDriver(options);
try {
driver.get("https://www.ianzhang.cn/s4ia/03-webdriver-advanced/interaction.html");
driver.findElement(By.id("alert-btn")).click();
Assertions.assertEquals(driver.switchTo().alert().getText(), "I am an alert");
} finally {
if (driver != null) driver.quit();
}
}
@Test
void bidiTest() {
ChromeOptions options = new ChromeOptions();
options.enableBiDi();
WebDriver driver = new ChromeDriver(options);
try {
driver.get("https://www.ianzhang.cn/s4ia/03-webdriver-advanced/interaction.html");
driver.findElement(By.id("alert-btn")).click();
Assertions.assertThrows(NoAlertPresentException.class, () -> driver.switchTo().alert());
} finally {
if (driver != null) driver.quit();
}
}
@Test
void noBidiFirefoxTest() {
FirefoxOptions options = new FirefoxOptions();
WebDriver driver = new FirefoxDriver(options);
try {
driver.get("https://www.ianzhang.cn/s4ia/03-webdriver-advanced/interaction.html");
driver.findElement(By.id("alert-btn")).click();
Assertions.assertEquals(driver.switchTo().alert().getText(), "I am an alert");
} finally {
if (driver != null) driver.quit();
}
}
@Test
void bidiFirefoxTest() {
FirefoxOptions options = new FirefoxOptions();
options.enableBiDi();
WebDriver driver = new FirefoxDriver(options);
try {
driver.get("https://www.ianzhang.cn/s4ia/03-webdriver-advanced/interaction.html");
driver.findElement(By.id("alert-btn")).click();
Assertions.assertEquals(driver.switchTo().alert().getText(), "I am an alert");
} finally {
if (driver != null) driver.quit();
}
}
}Relevant log output
N/AOperating System
Windows 11
Selenium version
Java 4.24.0
What are the browser(s) and version(s) where you see this issue?
Chrome 128.0.6613.114
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 128.0.6613.86
Are you using Selenium Grid?
N/A
Metadata
Metadata
Assignees
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!I-defectSomething is not working as intendedSomething is not working as intended