Bird
0
0

Find the issue in this code snippet:

medium📝 Debug Q7 of 15
Cypress - Element Interactions
Find the issue in this code snippet:
cy.get('#dropdown').select('Option 1').select('Option 2')
AThe selector '#dropdown' is invalid
BOptions must be passed as an array, not separate calls
CChaining multiple select() calls on the same element is incorrect
DThere is no issue; this code selects both options correctly
Step-by-Step Solution
Solution:
  1. Step 1: Understand chaining of select()

    Calling select() multiple times on the same element does not accumulate selections; it replaces the previous selection.
  2. Step 2: Correct approach for multiple selections

    To select multiple options, pass an array of option values or texts in a single select() call.
  3. Final Answer:

    Chaining multiple select() calls on the same element is incorrect -> Option C
  4. Quick Check:

    Use one select() call with array for multiple options [OK]
Quick Trick: Select multiple options in one call with array, not chained calls [OK]
Common Mistakes:
  • Chaining select() calls expecting cumulative selection
  • Passing single strings multiple times
  • Ignoring multi-select syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes