From c26a71e80cedabd6b630f5f71f598d800c3b3d2a Mon Sep 17 00:00:00 2001 From: g1879 Date: Mon, 24 Jun 2024 17:52:55 +0800 Subject: [PATCH] =?UTF-8?q?4.0.5.2=E4=BF=AE=E6=94=B9=E8=A7=86=E8=A7=89?= =?UTF-8?q?=E7=9B=B8=E5=AF=B9=E5=AE=9A=E4=BD=8D=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/__init__.py | 2 +- DrissionPage/_elements/chromium_element.py | 26 ++++++++++----------- DrissionPage/_elements/chromium_element.pyi | 10 ++++---- DrissionPage/common.py | 3 ++- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/DrissionPage/__init__.py b/DrissionPage/__init__.py index a35b899..ec0aac8 100644 --- a/DrissionPage/__init__.py +++ b/DrissionPage/__init__.py @@ -14,4 +14,4 @@ from ._configs.chromium_options import ChromiumOptions from ._configs.session_options import SessionOptions __all__ = ['ChromiumPage', 'ChromiumOptions', 'SessionOptions', 'SessionPage', 'WebPage', '__version__'] -__version__ = '4.0.5.0' +__version__ = '4.0.5.2' diff --git a/DrissionPage/_elements/chromium_element.py b/DrissionPage/_elements/chromium_element.py index 4ec98b7..75a05dd 100644 --- a/DrissionPage/_elements/chromium_element.py +++ b/DrissionPage/_elements/chromium_element.py @@ -366,37 +366,37 @@ class ChromiumElement(DrissionElement): except CDPError: return NoneElement(page=self.owner, method='offset()', args={'offset_x': offset_x, 'offset_y': offset_y}) - def east(self, locator=None, index=1): + def east(self, loc_or_pixel=None, index=1): """获取元素右边某个指定元素 - :param locator: 定位符,只支持str,且不支持xpath和css方式,传入int按像素距离获取 + :param loc_or_pixel: 定位符,只支持str,且不支持xpath和css方式,传入int按像素距离获取 :param index: 第几个,从1开始 :return: 获取到的元素对象 """ - return self._get_relative_eles(mode='east', locator=locator, index=index) + return self._get_relative_eles(mode='east', locator=loc_or_pixel, index=index) - def south(self, locator=None, index=1): + def south(self, loc_or_pixel=None, index=1): """获取元素下方某个指定元素 - :param locator: 定位符,只支持str,且不支持xpath和css方式,传入int按像素距离获取 + :param loc_or_pixel: 定位符,只支持str,且不支持xpath和css方式,传入int按像素距离获取 :param index: 第几个,从1开始 :return: 获取到的元素对象 """ - return self._get_relative_eles(mode='south', locator=locator, index=index) + return self._get_relative_eles(mode='south', locator=loc_or_pixel, index=index) - def west(self, locator=None, index=1): + def west(self, loc_or_pixel=None, index=1): """获取元素左边某个指定元素 - :param locator: 定位符,只支持str,且不支持xpath和css方式,传入int按像素距离获取 + :param loc_or_pixel: 定位符,只支持str,且不支持xpath和css方式,传入int按像素距离获取 :param index: 第几个,从1开始 :return: 获取到的元素对象 """ - return self._get_relative_eles(mode='west', locator=locator, index=index) + return self._get_relative_eles(mode='west', locator=loc_or_pixel, index=index) - def north(self, locator=None, index=1): + def north(self, loc_or_pixel=None, index=1): """获取元素上方某个指定元素 - :param locator: 定位符,只支持str,且不支持xpath和css方式,传入int按像素距离获取 + :param loc_or_pixel: 定位符,只支持str,且不支持xpath和css方式,传入int按像素距离获取 :param index: 第几个,从1开始 :return: 获取到的元素对象 """ - return self._get_relative_eles(mode='north', locator=locator, index=index) + return self._get_relative_eles(mode='north', locator=loc_or_pixel, index=index) def _get_relative_eles(self, mode='north', locator=None, index=1): """获取元素下方某个指定元素 @@ -445,7 +445,7 @@ class ChromiumElement(DrissionElement): return NoneElement(page=self.owner, method=f'{mode}()', args={'locator': locator}) num = 0 - value = -3 if minus else 3 + value = -8 if minus else 8 size = self.owner.rect.size max_len = size[0] if mode == 'east' else size[1] loc_data = locator_to_tuple(locator) if locator else None diff --git a/DrissionPage/_elements/chromium_element.pyi b/DrissionPage/_elements/chromium_element.pyi index 44ab46c..1be5553 100644 --- a/DrissionPage/_elements/chromium_element.pyi +++ b/DrissionPage/_elements/chromium_element.pyi @@ -161,15 +161,15 @@ class ChromiumElement(DrissionElement): def over(self, timeout: float = None) -> ChromiumElement: ... - def south(self, locator: str = None, index: int = 1) -> ChromiumElement: ... + def south(self, loc_or_pixel: Union[str, int, None] = None, index: int = 1) -> ChromiumElement: ... - def north(self, locator: str = None, index: int = 1) -> ChromiumElement: ... + def north(self, loc_or_pixel: Union[str, int, None] = None, index: int = 1) -> ChromiumElement: ... - def west(self, locator: str = None, index: int = 1) -> ChromiumElement: ... + def west(self, loc_or_pixel: Union[str, int, None] = None, index: int = 1) -> ChromiumElement: ... - def east(self, locator: str = None, index: int = 1) -> ChromiumElement: ... + def east(self, loc_or_pixel: Union[str, int, None] = None, index: int = 1) -> ChromiumElement: ... - def offset(self, offset_x, offset_y) -> ChromiumElement: ... + def offset(self, offset_x: int, offset_y: int) -> ChromiumElement: ... def _get_relative_eles(self, mode: str = 'north', diff --git a/DrissionPage/common.py b/DrissionPage/common.py index 3a414f8..eb9adac 100644 --- a/DrissionPage/common.py +++ b/DrissionPage/common.py @@ -7,9 +7,10 @@ """ from ._elements.session_element import make_session_ele from ._functions.by import By +from ._functions.elements import get_eles from ._functions.keys import Keys from ._functions.settings import Settings -from ._functions.tools import wait_until, configs_to_here, get_eles +from ._functions.tools import wait_until, configs_to_here from ._functions.web import get_blob, tree from ._pages.chromium_page import ChromiumPage from ._units.actions import Actions