Bird
0
0

Which of the following is the correct syntax to select an option by its visible text using cy.select()?

easy📝 Syntax Q12 of 15
Cypress - Element Interactions
Which of the following is the correct syntax to select an option by its visible text using cy.select()?
Acy.get('select').select('Option Text')
Bcy.get('select').selectByText('Option Text')
Ccy.select('select', 'Option Text')
Dcy.get('select').choose('Option Text')
Step-by-Step Solution
Solution:
  1. Step 1: Recall the correct cy.select() syntax

    The correct way is to first get the dropdown element with cy.get(), then call .select() with the visible text as argument.
  2. Step 2: Eliminate incorrect methods

    There is no selectByText() or choose() method in Cypress. Also, cy.select() is not called directly with selector and text.
  3. Final Answer:

    cy.get('select').select('Option Text') -> Option A
  4. Quick Check:

    Use cy.get().select(text) syntax [OK]
Quick Trick: Always use cy.get(selector).select(value) [OK]
Common Mistakes:
  • Using non-existent methods like selectByText()
  • Calling cy.select() without cy.get()
  • Using choose() instead of select()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes