From 0b964121464071d29cd4d880824945d0fffcb6fc Mon Sep 17 00:00:00 2001 From: g1879 Date: Wed, 30 Aug 2023 17:33:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`wait()`=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/setter.pyi | 2 ++ DrissionPage/waiter.py | 14 ++++++++++++++ DrissionPage/waiter.pyi | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/DrissionPage/setter.pyi b/DrissionPage/setter.pyi index 7e2748a..043c558 100644 --- a/DrissionPage/setter.pyi +++ b/DrissionPage/setter.pyi @@ -80,6 +80,8 @@ class SessionPageSetter(object): def retry_interval(self, interval: float) -> None: ... + def download_path(self, path: Union[str, Path]) -> None: ... + def timeout(self, second: float) -> None: ... def cookie(self, cookie: Union[Cookie, str, dict]) -> None: ... diff --git a/DrissionPage/waiter.py b/DrissionPage/waiter.py index 93d5d5b..69cba72 100644 --- a/DrissionPage/waiter.py +++ b/DrissionPage/waiter.py @@ -12,6 +12,13 @@ class ChromiumBaseWaiter(object): """ self._driver = page_or_ele + def __call__(self, second): + """等待若干秒 + :param second: 秒数 + :return: None + """ + sleep(second) + def ele_delete(self, loc_or_ele, timeout=None, raise_err=None): """等待元素从DOM中删除 :param loc_or_ele: 要等待的元素,可以是已有元素、定位符 @@ -223,6 +230,13 @@ class ChromiumElementWaiter(object): self._page = page self._ele = ele + def __call__(self, second): + """等待若干秒 + :param second: 秒数 + :return: None + """ + sleep(second) + def delete(self, timeout=None, raise_err=None): """等待元素从dom删除 :param timeout: 超时时间,为None使用元素所在页面timeout属性 diff --git a/DrissionPage/waiter.pyi b/DrissionPage/waiter.pyi index 66bbb43..59f272a 100644 --- a/DrissionPage/waiter.pyi +++ b/DrissionPage/waiter.pyi @@ -15,6 +15,8 @@ class ChromiumBaseWaiter(object): def __init__(self, page: ChromiumBase): self._driver: ChromiumBase = ... + def __call__(self, second: float) -> None: ... + def ele_delete(self, loc_or_ele: Union[str, tuple, ChromiumElement], timeout: float = None, raise_err: bool = None) -> bool: ... @@ -60,6 +62,8 @@ class ChromiumElementWaiter(object): self._ele: ChromiumElement = ... self._page: ChromiumBase = ... + def __call__(self, second: float) -> None: ... + def delete(self, timeout: float = None, raise_err: bool = None) -> bool: ... def display(self, timeout: float = None, raise_err: bool = None) -> bool: ...