diff --git a/DrissionPage/chromium_base.py b/DrissionPage/chromium_base.py index f4c6c7f..af7d051 100644 --- a/DrissionPage/chromium_base.py +++ b/DrissionPage/chromium_base.py @@ -876,6 +876,14 @@ class ChromiumBaseSetter(object): """返回用于设置页面滚动设置的对象""" 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): """设置超时时间,单位为秒 :param implicit: 查找元素超时时间 diff --git a/DrissionPage/chromium_base.pyi b/DrissionPage/chromium_base.pyi index 7b15baa..fb7d6d5 100644 --- a/DrissionPage/chromium_base.pyi +++ b/DrissionPage/chromium_base.pyi @@ -263,7 +263,11 @@ class ChromiumBaseSetter(object): @property 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: ... diff --git a/DrissionPage/chromium_element.py b/DrissionPage/chromium_element.py index b1a811e..a8f4b3f 100644 --- a/DrissionPage/chromium_element.py +++ b/DrissionPage/chromium_element.py @@ -683,7 +683,7 @@ class ChromiumElement(DrissionElement): :return: None """ 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): """右键单击""" @@ -697,7 +697,7 @@ class ChromiumElement(DrissionElement): :return: None """ 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): """中键单击""" @@ -1069,7 +1069,9 @@ class ChromiumShadowRoot(BaseElement): def _get_backend_id(self, node_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 @@ -1656,7 +1658,8 @@ class Click(object): try: self._ele.scroll.to_see() 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._ele.page.wait.load_start(wait_loading) return True diff --git a/DrissionPage/commons/browser.py b/DrissionPage/commons/browser.py index 0f4c8a8..6033996 100644 --- a/DrissionPage/commons/browser.py +++ b/DrissionPage/commons/browser.py @@ -171,7 +171,6 @@ def _run_browser(port, path: str, args) -> Popen: :param args: 启动参数 :return: 进程对象 """ - print(port) arguments = [path, f'--remote-debugging-port={port}'] arguments.extend(args) return Popen(arguments, shell=False) diff --git a/DrissionPage/session_page.py b/DrissionPage/session_page.py index 534944a..b36b95e 100644 --- a/DrissionPage/session_page.py +++ b/DrissionPage/session_page.py @@ -340,6 +340,14 @@ class SessionPageSetter(object): def __init__(self, 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): """设置连接超时时间 :param second: 秒数 diff --git a/DrissionPage/session_page.pyi b/DrissionPage/session_page.pyi index 2c61498..f98c450 100644 --- a/DrissionPage/session_page.pyi +++ b/DrissionPage/session_page.pyi @@ -163,6 +163,10 @@ class SessionPageSetter(object): def __init__(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 cookies(self, cookies: Union[RequestsCookieJar, list, tuple, str, dict]) -> None: ...