selenium滚动到顶部与底部

 1 #coding=utf-8
 2 from selenium import webdriver
 3 
 4 #滚动到浏览器顶部
 5 js_top = "var q=document.documentElement.scrollTop=0"
 6 
 7 #滚动到浏览器底部
 8 js_bottom = "var q=document.documentElement.scrollTop=10000"
 9 js_bottom2 = "window.scrollTo(0,document.body.scrollHeight)"
10 
11 driver = webdriver.Chrome()
12 driver.get(url)
13 driver.execute_script(js_bottom)
14 driver.execute_script(js_top)
15 driver.close()

 

posted @ 2018-07-20 12:46  lbw  阅读(1851)  评论(0编辑  收藏  举报