Bird
0
0

This App Action method is intended to log in a user:

medium📝 Debug Q14 of 15
Cypress - Test Organization and Patterns
This App Action method is intended to log in a user:
const login = (user, pass) => { cy.get('#username').type(user); cy.get('#password').type(pass); cy.get('#login-btn').click }

What is the error and how to fix it?
AMissing parentheses after click; fix by changing to <code>cy.get('#login-btn').click()</code>.
BWrong selector for username; fix by using <code>#user</code> instead of <code>#username</code>.
CMissing return statement; fix by adding <code>return</code> before cy commands.
DUsing arrow function incorrectly; fix by using function keyword.
Step-by-Step Solution
Solution:
  1. Step 1: Check method chaining syntax

    The click command is missing parentheses, so it is not called.
  2. Step 2: Fix the click command

    Add parentheses to call the function: click() to perform the click action.
  3. Final Answer:

    Missing parentheses after click; fix by changing to cy.get('#login-btn').click() -> Option A
  4. Quick Check:

    Method calls need parentheses [OK]
Quick Trick: Always add () to call Cypress commands like click [OK]
Common Mistakes:
  • Forgetting parentheses on Cypress commands
  • Changing selectors without verifying correctness
  • Thinking return is needed for Cypress commands

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes