4.1.0.4修复Chromium对象设置NoneElement_value无效的问题;修复@tx()=定位不是最底层元素问题

This commit is contained in:
g1879 2024-09-20 20:52:16 +08:00
parent 4c427042e3
commit 89c5dfbacf
5 changed files with 9 additions and 3 deletions

View File

@ -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'

View File

@ -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

View File

@ -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,

View File

@ -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 == '^': # 匹配开头

View File

@ -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)