How to test a scroll value of element for specific position? #26016
Unanswered
someApprentice
asked this question in
Questions and Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to test in my chat application that an element is scrolled down to the bottom on the first load and keeps scrolled down on new messages. I'm scrolling down using the following code snippet:
messagesElement.scrollTop = messagesElement.scrollHeight - messagesElement.offsetHeight;
I've managed to test that the element is scrolled down on the first load with following code:
But the second test with keeping element at the bottom sometimes fails. I'm using the following code:
As I understand it, cypress needs time to scroll the element down, but sometimes it doesn’t even enough 3 seconds to scroll down, and I don’t know how to write the test correctly. Also, using
wait(...)
method seems undoubtedly wrong.How can I write such a test?
*In the second video, in which the test fails, if you look closely, you can see how the element did not scroll to the very bottom.
DialogHOC.cy.tsx.pass.1sec.mp4
DialogHOC.cy.tsx.fail.mp4
Beta Was this translation helpful? Give feedback.
All reactions