Complete the code to switch to the alert.
Alert alert = driver.[1]();In Selenium Java, to switch to an alert, you use driver.switchTo().alert() with parentheses to call the method.
Complete the code to accept the unexpected alert.
driver.switchTo().alert().[1]();To accept an alert (click OK), use accept() method on the alert object.
Fix the error in the code to get alert text.
String alertText = driver.switchTo().alert().[1]();The correct method to get alert text is getText() with camel case and parentheses.
Fill both blanks to handle alert and print its text.
Alert alert = driver.[1](); System.out.println(alert.[2]());
First, switch to the alert with switchTo().alert(), then get its text with getText().
Fill all three blanks to handle unexpected alert by getting text, accepting it, and printing the message.
Alert alert = driver.[1](); String message = alert.[2](); alert.[3](); System.out.println(message);
Switch to alert, get its text, accept the alert to close it, then print the message.
