天天看點

python-selenium,關于頁面滑動

第一種:

#滑到底部

js="var q=document.documentElement.scrollTop=100000"

driver.execut_script(js)

目前在firefox,chrome上驗證都是可以跑通的

#滑動到頂部

js="var q=document.documentElement.scrollTop=0"

driver.execut_script(js)

第二種

#滑到底部

js="window.scrollTo(0,document.body.scrollHeight)"

driver.execute_script(js)

目前在firefox,chrome上驗證都是可以跑通的

#滑動到頂部

js="window.scrollTo(0,0)"

driver.execute_script(js)

scrollHeight 擷取對象的滾動高度。 

scrollLeft 設定或擷取位于對象左邊界和視窗中目前可見内容的最左端之間的距離。 

scrollTop 設定或擷取位于對象最頂端和視窗中可見内容的最頂端之間的距離。 

scrollWidth 擷取對象的滾動寬度。

轉載于:https://my.oschina.net/liyan2013/blog/3082813