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: 查找元素超时时间(秒),默认与页面等待时间一致