Bird
0
0

You want to scroll smoothly to the top-right corner of a page and then check if a button with id #submit is visible. Which of the following code snippets correctly achieves this?

hard📝 Application Q15 of 15
Cypress - Element Interactions
You want to scroll smoothly to the top-right corner of a page and then check if a button with id #submit is visible. Which of the following code snippets correctly achieves this?
Acy.scrollTo('topRight', 1000); cy.get('#submit').should('be.visible');
Bcy.scrollTo('topRight', { duration: 1000 }); cy.get('#submit').should('be.visible');
Ccy.scrollTo({ x: 'top', y: 'right' }, { smooth: true }); cy.get('#submit').should('be.visible');
Dcy.scrollTo('top', 'right', { smooth: true }); cy.get('#submit').should('be.visible');
Step-by-Step Solution
Solution:
  1. Step 1: Understand correct scrollTo syntax for smooth scroll

    Use position string like 'topRight' and options object with duration for animation.
  2. Step 2: Evaluate each option

    A uses correct syntax with position string and options object. B passes duration as second argument incorrectly. C uses invalid x/y strings and option name. D passes multiple strings incorrectly.
  3. Final Answer:

    cy.scrollTo('topRight', { duration: 1000 }); cy.get('#submit').should('be.visible'); -> Option B
  4. Quick Check:

    Position string + options object = correct [OK]
Quick Trick: Use position string and options object for smooth scroll [OK]
Common Mistakes:
  • Passing duration as a separate argument instead of options object
  • Using multiple position strings instead of one combined string
  • Using invalid option names like 'smooth'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes