Selenium Java - Handling Windows, Frames, and Alerts
Identify the error in this code snippet handling unexpected alerts:
try {
driver.findElement(By.id("login")).click();
} catch (NoAlertPresentException e) {
driver.switchTo().alert().accept();
}