[英]Scroll Firefox using Watir Webdriver
I'd like to scrape a website that dynamically generates more content as I scroll down the web browser. 当我向下滚动浏览器时,我想抓一个动态生成更多内容的网站。 I have seen a related post, Auto-Scroll in FireFox , but it doesn't answer my question.
我在FireFox中看过一篇相关文章Auto-Scroll ,但它没有回答我的问题。
Is it possible to scroll a webpage until the end of page (no more content is generated by the web server) or until a few refreshes using Watir web-driver? 是否可以滚动网页直到页面结束(Web服务器不再生成内容)或直到使用Watir Web驱动程序刷新一些内容?
I have recently tried to do something like that, and to my surprise looks like webdriver does not have support for scrolling. 我最近尝试过这样的事情,令我惊讶的是,webdriver似乎不支持滚动。 I did find two workarounds.
我找到了两个解决方法。
This will send space
to the browser, and it will scroll down (works on twitter.com, for example): 这将向浏览器发送
space
,它将向下滚动(例如,在twitter.com上工作):
browser.send_keys :space
This will scroll to the element, and if the element is at the bottom of the page, it will load more content: 这将滚动到元素,如果元素位于页面底部,它将加载更多内容:
browser.element.wd.location_once_scrolled_into_view
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.