From 7284b108ef6f2ba1128cfd490e1f6bc4391fb77d Mon Sep 17 00:00:00 2001 From: g1879 Date: Fri, 15 Dec 2023 09:15:52 +0800 Subject: [PATCH] =?UTF-8?q?4.0.0b22=E4=BF=AE=E5=A4=8D=E5=B0=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/__init__.py | 2 +- DrissionPage/_pages/chromium_frame.py | 5 +++-- DrissionPage/_units/states.py | 5 +++++ DrissionPage/_units/states.pyi | 6 ++++++ setup.py | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/DrissionPage/__init__.py b/DrissionPage/__init__.py index edd6064..c4cb7e4 100644 --- a/DrissionPage/__init__.py +++ b/DrissionPage/__init__.py @@ -13,4 +13,4 @@ from ._configs.chromium_options import ChromiumOptions from ._configs.session_options import SessionOptions __all__ = ['ChromiumPage', 'ChromiumOptions', 'SessionOptions', 'SessionPage', 'WebPage', '__version__'] -__version__ = '4.0.0b21' +__version__ = '4.0.0b22' diff --git a/DrissionPage/_pages/chromium_frame.py b/DrissionPage/_pages/chromium_frame.py index 55653c3..2c77f01 100644 --- a/DrissionPage/_pages/chromium_frame.py +++ b/DrissionPage/_pages/chromium_frame.py @@ -57,8 +57,9 @@ class ChromiumFrame(ChromiumBase): self._rect = None end_time = perf_counter() + 5 while perf_counter() < end_time: - if self.url is None or self.url == 'about:blank': - sleep(.1) + if self.url not in (None, 'about:blank'): + break + sleep(.1) def __call__(self, loc_or_str, timeout=None): """在内部查找元素 diff --git a/DrissionPage/_units/states.py b/DrissionPage/_units/states.py index 00dfde9..f1744f9 100644 --- a/DrissionPage/_units/states.py +++ b/DrissionPage/_units/states.py @@ -171,3 +171,8 @@ class FrameStates(object): return not (self._frame.frame_ele.style('visibility') == 'hidden' or self._frame.frame_ele.run_js('return this.offsetParent === null;') or self._frame.frame_ele.style('display') == 'none') + + @property + def has_alert(self): + """返回当前页面是否存在弹窗""" + return self._frame._has_alert diff --git a/DrissionPage/_units/states.pyi b/DrissionPage/_units/states.pyi index 102b1ea..fa8888c 100644 --- a/DrissionPage/_units/states.pyi +++ b/DrissionPage/_units/states.pyi @@ -85,3 +85,9 @@ class FrameStates(object): @property def ready_state(self) -> str: ... + + @property + def is_displayed(self) -> bool: ... + + @property + def has_alert(self) -> bool: ... diff --git a/setup.py b/setup.py index 7fc5b6b..9df76dc 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open("README.md", "r", encoding='utf-8') as fh: setup( name="DrissionPage", - version="4.0.0b21", + version="4.0.0b22", author="g1879", author_email="g1879@qq.com", description="Python based web automation tool. It can control the browser and send and receive data packets.",