Bird
0
0

Which of the following is the correct syntax to dismiss an alert in Selenium Java?

easy📝 Syntax Q3 of 15
Selenium Java - Handling Windows, Frames, and Alerts
Which of the following is the correct syntax to dismiss an alert in Selenium Java?
Adriver.switchTo().alert().accept();
Bdriver.switchTo().alert().sendKeys("dismiss");
Cdriver.switchTo().alert().dismiss();
Ddriver.switchTo().alert().close();
Step-by-Step Solution
Solution:
  1. Step 1: Identify dismiss method usage

    The dismiss() method is used to cancel or dismiss alerts.
  2. Step 2: Confirm correct syntax

    driver.switchTo().alert().dismiss() is the correct way to dismiss an alert.
  3. Final Answer:

    driver.switchTo().alert().dismiss(); -> Option C
  4. Quick Check:

    dismiss() = Cancel alert [OK]
Quick Trick: dismiss() cancels alert, accept() confirms it [OK]
Common Mistakes:
MISTAKES
  • Using accept() instead of dismiss()
  • Trying to sendKeys to dismiss alert
  • Using close() which is invalid for alerts

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes