mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
scroll_to()增加'half'方式,滚动半页
This commit is contained in:
parent
ef41df4629
commit
9ef2285712
@ -492,7 +492,7 @@ class DriverPage(object):
|
|||||||
|
|
||||||
def scroll_to(self, mode: str = 'bottom', pixel: int = 300) -> None:
|
def scroll_to(self, mode: str = 'bottom', pixel: int = 300) -> None:
|
||||||
"""按参数指示方式滚动页面 \n
|
"""按参数指示方式滚动页面 \n
|
||||||
:param mode: 可选滚动方向:'top', 'bottom', 'rightmost', 'leftmost', 'up', 'down', 'left', 'right'
|
:param mode: 可选滚动方向:'top', 'bottom', 'half', 'rightmost', 'leftmost', 'up', 'down', 'left', 'right'
|
||||||
:param pixel: 滚动的像素
|
:param pixel: 滚动的像素
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
@ -503,6 +503,10 @@ class DriverPage(object):
|
|||||||
self.driver.execute_script(
|
self.driver.execute_script(
|
||||||
"window.scrollTo(document.documentElement.scrollLeft,document.body.scrollHeight);")
|
"window.scrollTo(document.documentElement.scrollLeft,document.body.scrollHeight);")
|
||||||
|
|
||||||
|
elif mode == 'half':
|
||||||
|
self.driver.execute_script(
|
||||||
|
"window.scrollTo(document.documentElement.scrollLeft,document.body.scrollHeight/2);")
|
||||||
|
|
||||||
elif mode == 'rightmost':
|
elif mode == 'rightmost':
|
||||||
self.driver.execute_script("window.scrollTo(document.body.scrollWidth,document.documentElement.scrollTop);")
|
self.driver.execute_script("window.scrollTo(document.body.scrollWidth,document.documentElement.scrollTop);")
|
||||||
|
|
||||||
@ -523,7 +527,7 @@ class DriverPage(object):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Argument mode can only be 'top', 'bottom', 'rightmost', 'leftmost', 'up', 'down', 'left', 'right'.")
|
"Argument mode can only be 'top', 'bottom', 'half', 'rightmost', 'leftmost', 'up', 'down', 'left', 'right'.")
|
||||||
|
|
||||||
def refresh(self) -> None:
|
def refresh(self) -> None:
|
||||||
"""刷新当前页面"""
|
"""刷新当前页面"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user