From ff1ce0b6913ae6ed0b26c808c9316ffe0ce763db Mon Sep 17 00:00:00 2001 From: g1879 Date: Fri, 13 Sep 2024 22:50:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/_functions/elements.pyi | 4 ++++ DrissionPage/_pages/mix_tab.py | 4 ++-- DrissionPage/_pages/mix_tab.pyi | 2 +- DrissionPage/_pages/web_page.py | 4 ++-- DrissionPage/_pages/web_page.pyi | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/DrissionPage/_functions/elements.pyi b/DrissionPage/_functions/elements.pyi index 854548f..b15247f 100644 --- a/DrissionPage/_functions/elements.pyi +++ b/DrissionPage/_functions/elements.pyi @@ -31,6 +31,8 @@ class SessionElementsList(list): def __getitem__(self, _i) -> SessionElement: ... + def __iter__(self) -> List[SessionElement]: ... + @property def get(self) -> Getter: """返回用于属性的对象""" @@ -63,6 +65,8 @@ class ChromiumElementsList(SessionElementsList): def __getitem__(self, _i) -> ChromiumElement: ... + def __iter__(self) -> List[ChromiumElement]: ... + @property def filter(self) -> ChromiumFilter: """返回用于筛选多个元素的对象""" diff --git a/DrissionPage/_pages/mix_tab.py b/DrissionPage/_pages/mix_tab.py index 2b374c3..b0d972b 100644 --- a/DrissionPage/_pages/mix_tab.py +++ b/DrissionPage/_pages/mix_tab.py @@ -104,8 +104,8 @@ class MixTab(SessionPage, ChromiumTab, BasePage): return self.response def ele(self, locator, index=1, timeout=None): - return super(SessionPage, self).ele(locator, index=index, timeout=timeout) if self._d_mode \ - else super().ele(locator, index=index) + return (super(SessionPage, self).ele(locator, index=index, timeout=timeout) + if self._d_mode else super().ele(locator, index=index)) def eles(self, locator, timeout=None): return super(SessionPage, self).eles(locator, timeout=timeout) if self._d_mode else super().eles(locator) diff --git a/DrissionPage/_pages/mix_tab.pyi b/DrissionPage/_pages/mix_tab.pyi index abba2a9..066d908 100644 --- a/DrissionPage/_pages/mix_tab.pyi +++ b/DrissionPage/_pages/mix_tab.pyi @@ -215,7 +215,7 @@ class MixTab(SessionPage, ChromiumTab): def eles(self, locator: Union[Tuple[str, str], str], - timeout: float = None) -> ChromiumElementsList: + timeout: float = None) -> Union[ChromiumElementsList, SessionElementsList]: """返回页面中所有符合条件的元素、属性或节点文本 :param locator: 元素的定位信息,可以是loc元组,或查询字符串 :param timeout: 查找元素超时时间(秒),默认与页面等待时间一致 diff --git a/DrissionPage/_pages/web_page.py b/DrissionPage/_pages/web_page.py index 77094fe..52bff12 100644 --- a/DrissionPage/_pages/web_page.py +++ b/DrissionPage/_pages/web_page.py @@ -128,8 +128,8 @@ class WebPage(SessionPage, ChromiumPage, BasePage): return super().post(url, show_errmsg, retry, interval, **kwargs) def ele(self, locator, index=1, timeout=None): - return super(SessionPage, self).ele(locator, index=index, timeout=timeout) if self._d_mode \ - else super().ele(locator, index=index) + return (super(SessionPage, self).ele(locator, index=index, timeout=timeout) + if self._d_mode else super().ele(locator, index=index)) def eles(self, locator, timeout=None): return super(SessionPage, self).eles(locator, timeout=timeout) if self._d_mode else super().eles(locator) diff --git a/DrissionPage/_pages/web_page.pyi b/DrissionPage/_pages/web_page.pyi index a688ccd..c6b9f74 100644 --- a/DrissionPage/_pages/web_page.pyi +++ b/DrissionPage/_pages/web_page.pyi @@ -230,7 +230,7 @@ class WebPage(SessionPage, ChromiumPage, BasePage): def eles(self, locator: Union[Tuple[str, str], str], - timeout: float = None) -> ChromiumElementsList: + timeout: float = None) -> Union[ChromiumElementsList, SessionElementsList]: """返回页面中所有符合条件的元素、属性或节点文本 :param locator: 元素的定位信息,可以是loc元组,或查询字符串 :param timeout: 查找元素超时时间(秒),默认与页面等待时间一致