Bird
0
0

Identify the error in this Cypress test code:

medium📝 Debug Q14 of 15
Cypress - Basics and Setup
Identify the error in this Cypress test code:
describe('Login test', () => {
  it('logs in user', () => {
    cy.visit('https://app.com')
    cy.get('#username').type('user1')
    cy.get('#password').type('pass123')
    cy.get('button.submit').click
    cy.url().should('include', '/home')
  })
})
AWrong selector for username input
BMissing parentheses after click method
Ccy.visit URL is incorrect
DMissing assertion after typing password
Step-by-Step Solution
Solution:
  1. Step 1: Check method calls in the code

    The line cy.get('button.submit').click misses parentheses, so the click method is not called.
  2. Step 2: Verify other parts

    Selectors and URL look valid, and assertion after typing password is not required. The main error is missing parentheses on click.
  3. Final Answer:

    Missing parentheses after click method -> Option B
  4. Quick Check:

    Method calls need () = A [OK]
Quick Trick: Check all method calls have () after them [OK]
Common Mistakes:
  • Ignoring missing parentheses on click
  • Assuming selector is wrong without checking
  • Thinking cy.visit URL is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes