Bird
0
0

Why does getWindowHandles() return a Set instead of a List in Selenium Java?

hard📝 Conceptual Q10 of 15
Selenium Java - Handling Windows, Frames, and Alerts
Why does getWindowHandles() return a Set instead of a List in Selenium Java?
ABecause Lists cannot store String values
BBecause Sets allow duplicate window handles
CBecause window handles are unique and order does not matter
DBecause Sets maintain insertion order
Step-by-Step Solution
Solution:
  1. Step 1: Understand uniqueness of window handles

    Each window handle is unique; duplicates are not possible.
  2. Step 2: Recognize that order is not important

    The order of window handles is not guaranteed or required, so a Set is appropriate.
  3. Final Answer:

    Because window handles are unique and order does not matter -> Option C
  4. Quick Check:

    Set used for unique, unordered window handles [OK]
Quick Trick: Window handles are unique; order is irrelevant, so Set is used [OK]
Common Mistakes:
  • Thinking Sets allow duplicates
  • Assuming Lists cannot store Strings
  • Believing Sets maintain insertion order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes