Bird
0
0

Which Selenium WebDriver method is used to get all open window handles?

easy📝 Conceptual Q2 of 15
Selenium Java - Handling Windows, Frames, and Alerts
Which Selenium WebDriver method is used to get all open window handles?
Adriver.switchTo().window()
Bdriver.getWindowHandles()
Cdriver.getWindowHandle()
Ddriver.close()
Step-by-Step Solution
Solution:
  1. Step 1: Identify method for multiple windows

    The method getWindowHandles() returns a set of all window handles currently open.
  2. Step 2: Differentiate from similar methods

    getWindowHandle() returns only the current window handle, not all. switchTo().window() switches windows, and close() closes windows.
  3. Final Answer:

    driver.getWindowHandles() -> Option B
  4. Quick Check:

    getWindowHandles() = all windows [OK]
Quick Trick: Use getWindowHandles() to list all open windows [OK]
Common Mistakes:
  • Using getWindowHandle() instead of getWindowHandles()
  • Confusing switchTo().window() with getting handles
  • Trying to get handles after closing windows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes