JS控制滚动条的位置:
1. window.scrollTo(x,y);
竖向滚动条置顶 window.scrollTo(0,0);
竖向滚动条置底 window.scrollTo(0,document.body.scrollHeight)
2. JS控制TextArea滚动条自动滚动到最下部
document.getElementById('textarea').scrollTop = document.getElementById('textarea').scrollHeight
例子:
def scroll_up_down(number = 2):
for i in range(0,number):
driver.execute_script("window.scrollTo(0,document.body.scrollHeight)")
sleep(1)
driver.execute_script("window.scrollTo(0,0)")
sleep(1)
print("scroll up and down %s" %(i))
scroll_up_down(number=3)