diff --git a/DrissionPage/chromium_page.py b/DrissionPage/chromium_page.py index 715522f..70c2c81 100644 --- a/DrissionPage/chromium_page.py +++ b/DrissionPage/chromium_page.py @@ -84,7 +84,7 @@ class ChromiumPage(ChromiumBase): raise TypeError('只能接收Tab或DriverOptions类型参数。') self._first_run = False - self.main_tab = self.tab_id + self.main_tab: str = self.tab_id def _init_page(self, tab_id: str = None) -> None: """新建页面、页面刷新、切换标签页后要进行的cdp参数初始化 @@ -203,7 +203,7 @@ class ChromiumPage(ChromiumBase): self._control_session.get(f'http://{self.address}/json/new{url}') while len(self.tabs) < begin_len: pass - self.to_tab() + self.to_tab(self.tabs[0]) def to_main_tab(self) -> None: """跳转到主标签页""" @@ -220,12 +220,13 @@ class ChromiumPage(ChromiumBase): tab_id = self.main_tab if tab_id not in tabs: tab_id = tabs[0] - if tab_id == self.tab_id: - return if activate: self._control_session.get(f'http://{self.address}/json/activate/{tab_id}') + if tab_id == self.tab_id: + return + self._driver.stop() self._init_page(tab_id) if self.ready_state == 'complete': diff --git a/setup.py b/setup.py index 1842bbc..1002260 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.0.6", + version="3.0.7", author="g1879", author_email="g1879@qq.com", description="A module that integrates selenium and requests session, encapsulates common page operations.",