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.",