11. Switching to Alerts (accept, dismiss)

Alert Controls

Alert alert = driver.switchTo().alert();
System.out.println(alert.getText());
alert.accept();  // Clicks OK

Task

  • Switch to the active alert and call `alert.accept()`.
💡Common doubts
Did you like the problem?
Lesson 11 of 18
Java
Loading code editor…
Next