简体   繁体   中英

How to scroll down and up using splinter in python.

Not able to find command for scrolling using splinter. Wherever I have searched, can find only for selenium but not splinter.

You can scroll with standard javascript by using the Splinter method execute_script

Scroll To Top

browser.execute_script("window.scrollTo(0, 0);")

Scroll To Bottom

browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")

Prior answer is close but not correct

Scroll to bottom is:

    browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")

Adding to Tarun's answer,

If you would want to go midpage,

browser.execute_script("window.scrollTo(200, document.body.scrollHeight);")

maybe you want to go further down the page just increase the number

browser.execute_script("window.scrollTo(400, document.body.scrollHeight);")

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