黄瓜水豚滚动到页面底部

发布于 2024-10-06 23:44:04 字数 77 浏览 0 评论 0原文

我想使用我的 Cucumber/Capybara 设置来通过驱动浏览器并滚动到页面底部来测试无限滚动,以确保加载新内容。有办法做到这一点吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

甜味拾荒者 2024-10-13 23:44:04

您可以使用 javascript 来实现此目的:

page.execute_script "window.scrollBy(0,10000)"

You could use javascript to achieve this:

page.execute_script "window.scrollBy(0,10000)"
溇涏 2024-10-13 23:44:04

我通过“滚动到页面底部”步骤中的 visit '#footer' 解决了这个问题。

I solved this with visit '#footer' inside a "scroll to the bottom of the page" step.

以酷 2024-10-13 23:44:04

没有 jQuery 的解决方案或适应任何高度而不需要幻数:

page.execute_script('window.scrollTo(0, document.body.scrollHeight)')

A solution without jQuery or adapts to any height without magic numbers:

page.execute_script('window.scrollTo(0, document.body.scrollHeight)')
清醇 2024-10-13 23:44:04

例如:

page.scroll_to(find('footer'))

更多详细信息此处

As an example:

page.scroll_to(find('footer'))

More details here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文