I need to check the existence of Alert in WebDriver.
Sometimes it pops up an alert but sometimes it will not pop up. I need to check if the alert exists first, then
The following (C# implementation, but similar in Java) allows you to determine if there is an alert without exceptions and without creating the WebDriverWait object.
boolean isDialogPresent(WebDriver driver) {
IAlert alert = ExpectedConditions.AlertIsPresent().Invoke(driver);
return (alert != null);
}