Bird
0
0

Which of the following is the correct syntax to assert the URL exactly equals 'https://example.com/home' in Cypress?

easy📝 Syntax Q12 of 15
Cypress - Navigation and URL
Which of the following is the correct syntax to assert the URL exactly equals 'https://example.com/home' in Cypress?
Acy.url().should('contain', 'https://example.com/home')
Bcy.url().should('include', 'https://example.com/home')
Ccy.url().should('match', 'https://example.com/home')
Dcy.url().should('eq', 'https://example.com/home')
Step-by-Step Solution
Solution:
  1. Step 1: Identify exact match assertion

    The 'eq' assertion checks if the actual URL exactly equals the given string.
  2. Step 2: Match syntax to requirement

    Using cy.url().should('eq', 'https://example.com/home') asserts the URL is exactly that string.
  3. Final Answer:

    cy.url().should('eq', 'https://example.com/home') -> Option D
  4. Quick Check:

    Exact URL match uses 'eq' [OK]
Quick Trick: Use 'eq' for exact URL match, not 'include' or 'match' [OK]
Common Mistakes:
  • Using 'include' instead of 'eq' for exact match
  • Using 'match' without regex
  • Using 'contain' which is not a valid Cypress assertion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes