Bird
0
0

You have this Page Object method:

medium📝 Debug Q14 of 15
Cypress - Test Organization and Patterns
You have this Page Object method:
login(username, password) {
  cy.get('#user').type(username)
  cy.get('#pass').type(password)
  cy.get('button.login').click()
}

But your test calls cy.visit('/login') before login(), yet fails because the username input is not found. What is the likely problem?
AThe <code>click()</code> command must come before typing
BThe selector <code>#user</code> is incorrect or outdated
CThe method should use <code>cy.find()</code> instead of <code>cy.get()</code>
DYou forgot to call <code>cy.visit()</code> before login
Step-by-Step Solution
Solution:
  1. Step 1: Identify cause of element not found error

    If the username input is not found, the selector #user might be wrong or changed on the page.
  2. Step 2: Evaluate other options

    While missing cy.visit() can cause failure, the question states the failure is specifically about the username input not found, pointing to selector issue.
  3. Final Answer:

    The selector #user is incorrect or outdated -> Option B
  4. Quick Check:

    Element not found = wrong selector [OK]
Quick Trick: Element not found usually means wrong selector [OK]
Common Mistakes:
  • Assuming cy.find() fixes selector issues
  • Thinking click() must come before typing
  • Ignoring the need to visit page first

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes