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