WebDriverWait 等待 = new WebDriverWait(driver,Duration.ofMillis(5000));
wait.until(ExpectedConditions.alertIsPresent());
警报警报 = driver.switchTo().alert();
alert.accept();`
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for alert to be present (tried for 5 second(s) with 500 milliseconds interval) Build info: version: '4.8.3', revision: 'e5e76298c3' System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '20.0.1' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 115.0.5790.111, chrome: {chromedriverVersion: 115.0.5790.102 (90efd4b0ad6..., userDataDir: C:\Users\sande\AppData\Loca...}
I am getting No alert present exception and unable to continue execution of scripts
`
The selenium is very quick, so you have to provide the wait, please follow the code.
WebDriverWait wait = new WebDriverWait(driver, 10);
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
alert.accept();