Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
Cypress - Element Interactions
Identify the error in this code snippet:
cy.get('#container').scrollTo(100);
AscrollTo should be called without parentheses
BscrollTo cannot be used on elements
CThe selector '#container' is invalid
DscrollTo requires two arguments for x and y coordinates
Step-by-Step Solution
Solution:
  1. Step 1: Check scrollTo argument requirements

    scrollTo expects either two numbers (x, y) or a position string; a single number is invalid.
  2. Step 2: Validate other options

    scrollTo can be used on elements, selector is valid, and parentheses are required.
  3. Final Answer:

    scrollTo requires two arguments for x and y coordinates -> Option D
  4. Quick Check:

    scrollTo needs x and y or position string [OK]
Quick Trick: scrollTo(x, y) needs both coordinates or position string [OK]
Common Mistakes:
  • Passing only one coordinate
  • Thinking scrollTo can't target elements
  • Omitting parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes