Bird
0
0

Examine the following Cypress command:

medium📝 Debug Q7 of 15
Cypress - Element Interactions
Examine the following Cypress command:
cy.scrollTo('bottomRight');

What is the problem with this code?
AThe correct position string is 'bottomRight' but it must be passed as an object
BThe string 'bottomRight' is not a supported position; correct usage is 'bottomRight' with no quotes
CThe position string 'bottomRight' is invalid; it should be 'bottomRight' with camelCase
DThe correct position string is 'bottomRight' but Cypress only supports 'bottom' or 'right' separately
Step-by-Step Solution
Solution:
  1. Step 1: Check supported position strings

    Cypress supports positions like 'top', 'bottom', 'left', 'right', 'topLeft', 'topRight', 'bottomLeft', and 'bottomRight' (case-sensitive).
  2. Step 2: Verify the string used

    The string 'bottomRight' is valid only if spelled exactly as 'bottomRight' (camelCase). However, Cypress does support 'bottomRight' as a single string (camelCase).
  3. Step 3: Actual Cypress support

    According to Cypress documentation, 'bottomRight' is a valid position string and can be used directly.
  4. Final Answer:

    'bottomRight' is a valid position string in Cypress; there is no problem with the code -> Option C
  5. Quick Check:

    Check Cypress docs for valid position strings [OK]
Quick Trick: Use only supported position strings like 'bottomRight' [OK]
Common Mistakes:
  • Using unsupported position strings
  • Passing position strings without quotes
  • Assuming all corner positions are supported

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes