简体   繁体   中英

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.

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?

I have recently tried to do something like that, and to my surprise looks like webdriver does not have support for scrolling. I did find two workarounds.

This will send space to the browser, and it will scroll down (works on twitter.com, for example):

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM