Bird
0
0

Which of the following is the correct syntax to select the third option in a dropdown using Selenium Java's Select class?

easy📝 Syntax Q12 of 15
Selenium Java - Handling Form Elements
Which of the following is the correct syntax to select the third option in a dropdown using Selenium Java's Select class?
Aselect.selectByValue(3);
Bselect.selectByVisibleText(3);
Cselect.selectByIndex(2);
Dselect.selectByIndex(3);
Step-by-Step Solution
Solution:
  1. Step 1: Understand index numbering in Select

    Indexing in Select starts at 0, so the third option has index 2.
  2. Step 2: Choose correct method and index

    Using selectByIndex(2) selects the third option correctly.
  3. Final Answer:

    select.selectByIndex(2); -> Option C
  4. Quick Check:

    Index 2 selects third option [OK]
Quick Trick: Remember index starts at 0, so third option is index 2 [OK]
Common Mistakes:
  • Using index 3 for third option (off-by-one error)
  • Passing integer to selectByVisibleText instead of string
  • Using selectByValue with an integer instead of string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes