I'd like to use my Cucumber/Capybara setup to test endless scroll by driving a browser and scrolling to the bottom of the page to ensure that the new content is loaded. Is there a way to do this?
You could use javascript to achieve this:
page.execute_script "window.scrollBy(0,10000)"
-
8For Google purposes, I got here with the error "unknown error: Element is not clickable at point (750, 341). Other element would receive the click" and the solution was
page.execute_script "window.scrollBy(0,500)"
. Thanks! – Dan Kohn Dec 15 '14 at 19:43 -
4If you have jQuery available you can run
window.scrollBy(0, $(window).height())
– Drew May 31 '16 at 17:19 -
Unfortunately, this doesn't work in my Angular app, I don't know why yet. – ZedTuX Feb 22 '19 at 9:13
-
To be just as nitpicky as your comment on visit '#footer', this only works if your page is less than 10000 units high. – Arnaud Meuret Oct 1 '19 at 6:34
-
I solved this with visit '#footer' inside a "scroll to the bottom of the page" step.
-
2This only works if you have an element with an
id
offooter
. It also assumes (reasonably) that the footer is at the bottom of the page... – Nat Ritmeyer Aug 13 '13 at 18:55 -
-
3
-
1Indeed :) But have you never seen a #footer that isn't at the bottom of the page? – Nat Ritmeyer Jan 29 '14 at 17:21
-
1more than discussing where the footer is placed, it assumes the footer was loaded! I got here looking for a way to take page screenshots of the bottom parts and, if there's some failure on the page, that method won't work :/ The JS solution is a bit safer in those cases. – igorsantos07 Apr 24 '17 at 4:18