There is the scrollIntoView
and the scrollTo
. Both of them scroll only for a specific duration of time. E.g. the cy.scrollTo(100, 100)
won't scroll at all, because the default duration is 0
and the cy.scrollTo(10000, 10000, { duration: 1000 })
won't actually scroll ten thousand pixels, but only as many pixels as it will be able to scroll in 1000 milliseconds.
So, I would have to put a big duration
value and hope for the scroll to complete. And my question is: Is it possible in Cypress to scroll the specific number of pixels irrespectively of how much time it will take?
I.e. I need the cy.scrollTo(100, 100)
to actually scroll 100 pixels and the cy.scrollTo(10000, 10000, { duration: 1000 })
to also scroll the actual 10000 pixels. The size of my containers may change (due to the variable contained data), so it makes zero sense for me to try to guess the number I need to put in the duration
.
Adding the wait(0)
after the scrollTo(100, 100)
did the trick. I.e. : scrollTo(100, 100).wait(0)
.