diff --git a/DrissionPage/__init__.py b/DrissionPage/__init__.py index f5a3c61..d4d0162 100644 --- a/DrissionPage/__init__.py +++ b/DrissionPage/__init__.py @@ -12,4 +12,4 @@ from ._pages.chromium_page import ChromiumPage from ._pages.session_page import SessionPage from ._pages.web_page import WebPage -__version__ = '4.1.0.3' +__version__ = '4.1.0.4' diff --git a/DrissionPage/_base/chromium.py b/DrissionPage/_base/chromium.py index 8475eee..3eeb268 100644 --- a/DrissionPage/_base/chromium.py +++ b/DrissionPage/_base/chromium.py @@ -72,6 +72,8 @@ class Chromium(object): self._load_mode = self._chromium_options.load_mode self._download_path = str(Path(self._chromium_options.download_path).absolute()) self._auto_handle_alert = None + self._none_ele_return_value = False + self._none_ele_value = None self.retry_times = self._chromium_options.retry_times self.retry_interval = self._chromium_options.retry_interval self.address = self._chromium_options.address diff --git a/DrissionPage/_base/chromium.pyi b/DrissionPage/_base/chromium.pyi index d94cf6b..9c613d5 100644 --- a/DrissionPage/_base/chromium.pyi +++ b/DrissionPage/_base/chromium.pyi @@ -6,7 +6,7 @@ @License : BSD 3-Clause. """ from threading import Lock -from typing import List, Optional, Set, Dict, Union, Tuple, Literal +from typing import List, Optional, Set, Dict, Union, Tuple, Literal, Any from .driver import BrowserDriver, Driver from .._configs.chromium_options import ChromiumOptions @@ -49,6 +49,8 @@ class Chromium(object): _is_exists: bool = ... _is_headless: bool = ... _disconnect_flag: bool = ... + _none_ele_return_value: bool = ... + _none_ele_value: Any = ... def __new__(cls, addr_or_opts: Union[str, int, ChromiumOptions] = None, diff --git a/DrissionPage/_functions/locator.py b/DrissionPage/_functions/locator.py index a915451..b802877 100644 --- a/DrissionPage/_functions/locator.py +++ b/DrissionPage/_functions/locator.py @@ -225,7 +225,7 @@ def _make_single_xpath_str(tag: str, text: str) -> tuple: else: symbol = r[1] if symbol == '=': # 精确查找 - arg = '.' if r[0] in ('@text()', '@tx()') else r[0] + arg = 'text()' if r[0] in ('@text()', '@tx()') else r[0] arg_str = f'{arg}={_make_search_str(r[2])}' elif symbol == '^': # 匹配开头 diff --git a/DrissionPage/_pages/chromium_tab.py b/DrissionPage/_pages/chromium_tab.py index a708963..0d6e72e 100644 --- a/DrissionPage/_pages/chromium_tab.py +++ b/DrissionPage/_pages/chromium_tab.py @@ -47,6 +47,8 @@ class ChromiumTab(ChromiumBase): self._load_mode = self.browser._load_mode self._download_path = self.browser.download_path self._auto_handle_alert = self.browser._auto_handle_alert + self._none_ele_return_value = self.browser._none_ele_return_value + self._none_ele_value = self.browser._none_ele_value def close(self, others=False): self.browser.close_tabs(self.tab_id, others=others)