Bird
0
0

Why might selecting an option by visible text fail even if the text appears correct in Selenium Java?

hard📝 Conceptual Q10 of 15
Selenium Java - Handling Form Elements
Why might selecting an option by visible text fail even if the text appears correct in Selenium Java?
AText has leading/trailing spaces or hidden characters
BselectByVisibleText only works with lowercase text
CDropdown options must be selected by value only
DSelenium cannot select options by visible text
Step-by-Step Solution
Solution:
  1. Step 1: Understand visible text matching

    selectByVisibleText matches exact text including spaces and hidden characters.
  2. Step 2: Identify common failure cause

    If the visible text has extra spaces or invisible characters, the match fails even if it looks correct.
  3. Final Answer:

    Text has leading/trailing spaces or hidden characters -> Option A
  4. Quick Check:

    Exact text match needed for selectByVisibleText [OK]
Quick Trick: Trim text or check hidden chars for visible text selection [OK]
Common Mistakes:
  • Assuming case-insensitive match
  • Believing only value selection works
  • Ignoring whitespace issues

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes