Bird
0
0

You want to select all visible input elements inside a form with id loginForm and type text into the first one. Which chaining is correct?

hard📝 Application Q8 of 15
Cypress - Selecting Elements
You want to select all visible input elements inside a form with id loginForm and type text into the first one. Which chaining is correct?
Acy.get('#loginForm').find('input:visible').first().type('user')
Bcy.get('input:visible').find('#loginForm').first().type('user')
Ccy.find('#loginForm').get('input:visible').type('user')
Dcy.get('#loginForm input').type('user').first()
Step-by-Step Solution
Solution:
  1. Step 1: Select form by id

    Use cy.get('#loginForm') to select the form element.
  2. Step 2: Find visible inputs inside form

    Chain .find('input:visible') to get visible inputs inside the form.
  3. Step 3: Select first input and type

    Use .first() to select the first input, then .type('user') to enter text.
  4. Final Answer:

    cy.get('#loginForm').find('input:visible').first().type('user') -> Option A
  5. Quick Check:

    Parent get, find visible inputs, first, then type = cy.get('#loginForm').find('input:visible').first().type('user') [OK]
Quick Trick: Chain get(), find(), first() before typing [OK]
Common Mistakes:
  • Starting chain with cy.find()
  • Using find() before get()
  • Typing before selecting first input

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes