mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
页面对象添加重试次数和间隔设置;点击input元素时点击中点
This commit is contained in:
parent
387bc8a047
commit
51ce706cd7
@ -876,6 +876,14 @@ class ChromiumBaseSetter(object):
|
|||||||
"""返回用于设置页面滚动设置的对象"""
|
"""返回用于设置页面滚动设置的对象"""
|
||||||
return PageScrollSetter(self._page.scroll)
|
return PageScrollSetter(self._page.scroll)
|
||||||
|
|
||||||
|
def retry_times(self, times):
|
||||||
|
"""设置连接失败重连次数"""
|
||||||
|
self._page.retry_times = times
|
||||||
|
|
||||||
|
def retry_interval(self, interval):
|
||||||
|
"""设置连接失败重连间隔"""
|
||||||
|
self._page.retry_interval = interval
|
||||||
|
|
||||||
def timeouts(self, implicit=None, page_load=None, script=None):
|
def timeouts(self, implicit=None, page_load=None, script=None):
|
||||||
"""设置超时时间,单位为秒
|
"""设置超时时间,单位为秒
|
||||||
:param implicit: 查找元素超时时间
|
:param implicit: 查找元素超时时间
|
||||||
|
@ -263,7 +263,11 @@ class ChromiumBaseSetter(object):
|
|||||||
@property
|
@property
|
||||||
def scroll(self) -> PageScrollSetter: ...
|
def scroll(self) -> PageScrollSetter: ...
|
||||||
|
|
||||||
def timeouts(self, implicit: float = None, page_load: float = None, script: float = None): ...
|
def retry_times(self, times: int) -> None: ...
|
||||||
|
|
||||||
|
def retry_interval(self, interval: float) -> None: ...
|
||||||
|
|
||||||
|
def timeouts(self, implicit: float = None, page_load: float = None, script: float = None) -> None: ...
|
||||||
|
|
||||||
def user_agent(self, ua: str, platform: str = None) -> None: ...
|
def user_agent(self, ua: str, platform: str = None) -> None: ...
|
||||||
|
|
||||||
|
@ -683,7 +683,7 @@ class ChromiumElement(DrissionElement):
|
|||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
warn("click_at()方法即将弃用,请用click.left_at()方法代替。", DeprecationWarning)
|
warn("click_at()方法即将弃用,请用click.left_at()方法代替。", DeprecationWarning)
|
||||||
self.click.left_at(offset_x, offset_y)
|
self.click.at(offset_x, offset_y, 'left')
|
||||||
|
|
||||||
def r_click(self):
|
def r_click(self):
|
||||||
"""右键单击"""
|
"""右键单击"""
|
||||||
@ -697,7 +697,7 @@ class ChromiumElement(DrissionElement):
|
|||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
warn("r_click_at()方法即将弃用,请用click.right_at()方法代替。", DeprecationWarning)
|
warn("r_click_at()方法即将弃用,请用click.right_at()方法代替。", DeprecationWarning)
|
||||||
self.click.right_at(offset_x, offset_y)
|
self.click.at(offset_x, offset_y, 'right')
|
||||||
|
|
||||||
def m_click(self):
|
def m_click(self):
|
||||||
"""中键单击"""
|
"""中键单击"""
|
||||||
@ -1069,7 +1069,9 @@ class ChromiumShadowRoot(BaseElement):
|
|||||||
|
|
||||||
def _get_backend_id(self, node_id):
|
def _get_backend_id(self, node_id):
|
||||||
"""返回元素object id"""
|
"""返回元素object id"""
|
||||||
return self.page.run_cdp('DOM.describeNode', nodeId=node_id)['node']['backendNodeId']
|
r = self.page.run_cdp('DOM.describeNode', nodeId=node_id)['node']
|
||||||
|
self._tag = r['localName'].lower()
|
||||||
|
return r['backendNodeId']
|
||||||
|
|
||||||
# ------------准备废弃--------------
|
# ------------准备废弃--------------
|
||||||
@property
|
@property
|
||||||
@ -1656,7 +1658,8 @@ class Click(object):
|
|||||||
try:
|
try:
|
||||||
self._ele.scroll.to_see()
|
self._ele.scroll.to_see()
|
||||||
if (self._ele.states.is_in_viewport and not self._ele.states.is_covered) or by_js is False:
|
if (self._ele.states.is_in_viewport and not self._ele.states.is_covered) or by_js is False:
|
||||||
client_x, client_y = self._ele.locations.viewport_click_point
|
client_x, client_y = self._ele.locations.viewport_midpoint if self._ele.tag == 'input' \
|
||||||
|
else self._ele.locations.viewport_click_point
|
||||||
self._click(client_x, client_y)
|
self._click(client_x, client_y)
|
||||||
self._ele.page.wait.load_start(wait_loading)
|
self._ele.page.wait.load_start(wait_loading)
|
||||||
return True
|
return True
|
||||||
|
@ -171,7 +171,6 @@ def _run_browser(port, path: str, args) -> Popen:
|
|||||||
:param args: 启动参数
|
:param args: 启动参数
|
||||||
:return: 进程对象
|
:return: 进程对象
|
||||||
"""
|
"""
|
||||||
print(port)
|
|
||||||
arguments = [path, f'--remote-debugging-port={port}']
|
arguments = [path, f'--remote-debugging-port={port}']
|
||||||
arguments.extend(args)
|
arguments.extend(args)
|
||||||
return Popen(arguments, shell=False)
|
return Popen(arguments, shell=False)
|
||||||
|
@ -340,6 +340,14 @@ class SessionPageSetter(object):
|
|||||||
def __init__(self, page):
|
def __init__(self, page):
|
||||||
self._page = page
|
self._page = page
|
||||||
|
|
||||||
|
def retry_times(self, times):
|
||||||
|
"""设置连接失败时重连次数"""
|
||||||
|
self._page.retry_times = times
|
||||||
|
|
||||||
|
def retry_interval(self, interval):
|
||||||
|
"""设置连接失败时重连间隔"""
|
||||||
|
self._page.retry_interval = interval
|
||||||
|
|
||||||
def timeout(self, second):
|
def timeout(self, second):
|
||||||
"""设置连接超时时间
|
"""设置连接超时时间
|
||||||
:param second: 秒数
|
:param second: 秒数
|
||||||
|
@ -163,6 +163,10 @@ class SessionPageSetter(object):
|
|||||||
def __init__(self, page: SessionPage):
|
def __init__(self, page: SessionPage):
|
||||||
self._page: SessionPage = ...
|
self._page: SessionPage = ...
|
||||||
|
|
||||||
|
def retry_times(self, times: int) -> None: ...
|
||||||
|
|
||||||
|
def retry_interval(self, interval: float) -> None: ...
|
||||||
|
|
||||||
def timeout(self, second: float) -> None: ...
|
def timeout(self, second: float) -> None: ...
|
||||||
|
|
||||||
def cookies(self, cookies: Union[RequestsCookieJar, list, tuple, str, dict]) -> None: ...
|
def cookies(self, cookies: Union[RequestsCookieJar, list, tuple, str, dict]) -> None: ...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user