From 89c5dfbacf9a645ac2f0a30532263a69514f8e1d Mon Sep 17 00:00:00 2001 From: g1879 Date: Fri, 20 Sep 2024 20:52:16 +0800 Subject: [PATCH] =?UTF-8?q?4.1.0.4=E4=BF=AE=E5=A4=8DChromium=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E8=AE=BE=E7=BD=AENoneElement=5Fvalue=E6=97=A0?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?@tx()=3D=E5=AE=9A=E4=BD=8D=E4=B8=8D=E6=98=AF=E6=9C=80=E5=BA=95?= =?UTF-8?q?=E5=B1=82=E5=85=83=E7=B4=A0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/__init__.py | 2 +- DrissionPage/_base/chromium.py | 2 ++ DrissionPage/_base/chromium.pyi | 4 +++- DrissionPage/_functions/locator.py | 2 +- DrissionPage/_pages/chromium_tab.py | 2 ++ 5 files changed, 9 insertions(+), 3 deletions(-) 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)