Bird
0
0

Which Selenium WebDriver method is used to switch control to a prompt alert?

easy📝 Conceptual Q2 of 15
Selenium Java - Handling Windows, Frames, and Alerts
Which Selenium WebDriver method is used to switch control to a prompt alert?
Adriver.switchTo().prompt()
Bdriver.getAlert()
Cdriver.switchTo().alert()
Ddriver.alert()
Step-by-Step Solution
Solution:
  1. Step 1: Recall Selenium alert handling methods

    The correct method to switch to any alert (simple, confirmation, prompt) is driver.switchTo().alert().
  2. Step 2: Verify method names

    Methods like getAlert(), prompt(), or alert() do not exist in Selenium WebDriver API.
  3. Final Answer:

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

    Switch to alert = driver.switchTo().alert() [OK]
Quick Trick: Use driver.switchTo().alert() for all alert types [OK]
Common Mistakes:
  • Using non-existent methods like getAlert()
  • Confusing prompt() with alert()
  • Trying to switch without switchTo()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes