From b5892c622bce76886b70b7a1c34d0121f3208467 Mon Sep 17 00:00:00 2001 From: g1879 Date: Thu, 2 Feb 2023 23:35:57 +0800 Subject: [PATCH] =?UTF-8?q?3.1.3ChromiumBase=E7=9A=84title=E3=80=81url?= =?UTF-8?q?=E3=80=81html=E7=AD=89=E5=BE=85=E5=8A=A0=E8=BD=BD=E7=BB=93?= =?UTF-8?q?=E6=9D=9F=E6=89=8D=E8=BF=94=E5=9B=9E=EF=BC=9Bwait=5Floading()?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=BD=BF=E7=94=A8=E9=A1=B5=E9=9D=A2timeout?= =?UTF-8?q?=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/chromium_base.py | 9 ++++++--- DrissionPage/web_page.py | 1 + setup.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/DrissionPage/chromium_base.py b/DrissionPage/chromium_base.py index ccc7510..9ddcc9e 100644 --- a/DrissionPage/chromium_base.py +++ b/DrissionPage/chromium_base.py @@ -198,6 +198,7 @@ class ChromiumBase(BasePage): @property def title(self): """返回当前页面title""" + self._wait_loaded() return self._tab_obj.Target.getTargetInfo(targetId=self.tab_id)['targetInfo']['title'] @property @@ -225,11 +226,13 @@ class ChromiumBase(BasePage): @property def url(self): """返回当前页面url""" + self._wait_loaded() return self._tab_obj.Target.getTargetInfo(targetId=self.tab_id)['targetInfo']['url'] @property def html(self): """返回当前页面html文本""" + self._wait_loaded() return self._wait_driver.DOM.getOuterHTML(objectId=self._root_id)['outerHTML'] @property @@ -338,13 +341,13 @@ class ChromiumBase(BasePage): timeout=timeout) return self._url_available - def wait_loading(self, timeout=1): + def wait_loading(self, timeout=None): """阻塞程序,等待页面进入加载状态 :param timeout: 超时时间 :return: 等待结束时是否进入加载状态 """ - if timeout: - timeout = 2 if timeout is True else timeout + if timeout != 0: + timeout = self.timeout if timeout in (None, True) else timeout end_time = perf_counter() + timeout while perf_counter() < end_time: if self.is_loading: diff --git a/DrissionPage/web_page.py b/DrissionPage/web_page.py index 0084aed..d4174d4 100644 --- a/DrissionPage/web_page.py +++ b/DrissionPage/web_page.py @@ -318,6 +318,7 @@ class WebPage(SessionPage, ChromiumPage, BasePage): :param mode: 模式字符串 :param go: 是否跳转到原模式的url :param copy_cookies: 是否复制cookies到目标模式 + :return: None """ if mode is not None and mode.lower() == self._mode: return diff --git a/setup.py b/setup.py index d893698..75818d4 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="3.1.2", + version="3.1.3", author="g1879", author_email="g1879@qq.com", description="A module that integrates selenium and requests session, encapsulates common page operations.",