mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
优化元素筛选,未完成
This commit is contained in:
parent
143bd191c1
commit
5ffff60118
@ -12,6 +12,7 @@ from DownloadKit import DownloadKit
|
||||
|
||||
from .._elements.none_element import NoneElement
|
||||
from .._elements.session_element import SessionElement
|
||||
from .._functions.elements import SessionElementsList
|
||||
from .._pages.chromium_page import ChromiumPage
|
||||
from .._pages.session_page import SessionPage
|
||||
from .._pages.web_page import WebPage
|
||||
@ -37,7 +38,7 @@ class BaseParser(object):
|
||||
locator: Union[Tuple[str, str], str, BaseElement, None] = None,
|
||||
index: int = 1) -> SessionElement: ...
|
||||
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str]) -> List[SessionElement]: ...
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str]) -> SessionElementsList: ...
|
||||
|
||||
def _ele(self,
|
||||
locator: Union[Tuple[str, str], str],
|
||||
|
@ -18,7 +18,7 @@ from .session_element import make_session_ele
|
||||
from .._base.base import DrissionElement, BaseElement
|
||||
from .._functions.keys import input_text_or_keys
|
||||
from .._functions.locator import get_loc
|
||||
from .._functions.elements import ElementsList
|
||||
from .._functions.elements import ChromiumElementsList
|
||||
from .._functions.web import make_absolute_link, get_ele_txt, format_html, is_js_func, offset_scroll, get_blob
|
||||
from .._units.clicker import Clicker
|
||||
from .._units.rect import ElementRect
|
||||
@ -1199,7 +1199,7 @@ def find_by_xpath(ele, xpath, index, timeout, relative=True):
|
||||
res = ele.owner.run_cdp('Runtime.getProperties', objectId=res['result']['objectId'],
|
||||
ownProperties=True)['result'][:-1]
|
||||
if index is None:
|
||||
r = ElementsList()
|
||||
r = ChromiumElementsList(ele.owner)
|
||||
for i in res:
|
||||
if i['value']['type'] == 'object':
|
||||
r.append(make_chromium_eles(ele.owner, _ids=i['value']['objectId'], is_obj_id=True))
|
||||
@ -1228,7 +1228,7 @@ def find_by_xpath(ele, xpath, index, timeout, relative=True):
|
||||
|
||||
if result:
|
||||
return result
|
||||
return NoneElement(ele.owner) if index is not None else ElementsList()
|
||||
return NoneElement(ele.owner) if index is not None else ChromiumElementsList(ele.owner)
|
||||
|
||||
|
||||
def find_by_css(ele, selector, index, timeout):
|
||||
@ -1274,7 +1274,7 @@ def find_by_css(ele, selector, index, timeout):
|
||||
|
||||
if result:
|
||||
return result
|
||||
return NoneElement(ele.owner) if index is not None else ElementsList()
|
||||
return NoneElement(ele.owner) if index is not None else ChromiumElementsList(ele.owner)
|
||||
|
||||
|
||||
def make_chromium_eles(page, _ids, index=1, is_obj_id=True, ele_only=False):
|
||||
@ -1306,7 +1306,7 @@ def make_chromium_eles(page, _ids, index=1, is_obj_id=True, ele_only=False):
|
||||
return get_node_func(page, obj_id, ele_only)
|
||||
|
||||
else: # 获取全部
|
||||
nodes = ElementsList()
|
||||
nodes = ChromiumElementsList()
|
||||
for obj_id in _ids:
|
||||
tmp = get_node_func(page, obj_id, ele_only)
|
||||
if tmp is False:
|
||||
|
@ -10,7 +10,7 @@ from typing import Union, Tuple, List, Any, Literal, Optional
|
||||
|
||||
from .._base.base import DrissionElement, BaseElement
|
||||
from .._elements.session_element import SessionElement
|
||||
from .._functions.elements import ElementsList
|
||||
from .._functions.elements import SessionElementsList, ChromiumElementsList
|
||||
from .._pages.chromium_base import ChromiumBase
|
||||
from .._pages.chromium_frame import ChromiumFrame
|
||||
from .._pages.chromium_page import ChromiumPage
|
||||
@ -201,21 +201,20 @@ class ChromiumElement(DrissionElement):
|
||||
|
||||
def eles(self,
|
||||
locator: Union[Tuple[str, str], str],
|
||||
timeout: float = None) -> ElementsList: ...
|
||||
timeout: float = None) -> ChromiumElementsList: ...
|
||||
|
||||
def s_ele(self,
|
||||
locator: Union[Tuple[str, str], str] = None,
|
||||
index: int = 1) -> SessionElement: ...
|
||||
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str] = None) -> List[SessionElement]: ...
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str] = None) -> SessionElementsList: ...
|
||||
|
||||
def _find_elements(self,
|
||||
locator: Union[Tuple[str, str], str],
|
||||
timeout: float = None,
|
||||
index: Optional[int] = 1,
|
||||
relative: bool = False,
|
||||
raise_err: bool = False) -> Union[ChromiumElement, ChromiumFrame,
|
||||
List[Union[ChromiumElement, ChromiumFrame]]]: ...
|
||||
raise_err: bool = False) -> Union[ChromiumElement, ChromiumFrame, ChromiumElementsList]: ...
|
||||
|
||||
def style(self, style: str, pseudo_ele: str = '') -> str: ...
|
||||
|
||||
@ -331,13 +330,13 @@ class ShadowRoot(BaseElement):
|
||||
|
||||
def eles(self,
|
||||
locator: Union[Tuple[str, str], str],
|
||||
timeout: float = None) -> ElementsList: ...
|
||||
timeout: float = None) -> ChromiumElementsList: ...
|
||||
|
||||
def s_ele(self,
|
||||
locator: Union[Tuple[str, str], str] = None,
|
||||
index: int = 1) -> SessionElement: ...
|
||||
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str]) -> List[SessionElement]: ...
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str]) -> SessionElementsList: ...
|
||||
|
||||
def _find_elements(self,
|
||||
locator: Union[Tuple[str, str], str],
|
||||
@ -379,7 +378,7 @@ def make_chromium_eles(page: Union[ChromiumBase, ChromiumPage, WebPage, Chromium
|
||||
index: Optional[int] = 1,
|
||||
is_obj_id: bool = True,
|
||||
ele_only: bool = False
|
||||
) -> Union[ChromiumElement, ChromiumFrame, List[Union[ChromiumElement, ChromiumFrame]]]: ...
|
||||
) -> Union[ChromiumElement, ChromiumFrame, ChromiumElementsList]: ...
|
||||
|
||||
|
||||
def make_js_for_find_ele_by_xpath(xpath: str, type_txt: str, node_txt: str) -> str: ...
|
||||
|
@ -13,6 +13,7 @@ from lxml.html import HtmlElement, fromstring
|
||||
|
||||
from .none_element import NoneElement
|
||||
from .._base.base import DrissionElement, BasePage, BaseElement
|
||||
from .._functions.elements import SessionElementsList
|
||||
from .._functions.locator import get_loc
|
||||
from .._functions.web import get_ele_txt, make_absolute_link
|
||||
|
||||
@ -401,7 +402,11 @@ def make_session_ele(html_or_ele, loc=None, index=1, method=None):
|
||||
|
||||
# 把lxml元素对象包装成SessionElement对象并按需要返回一个或全部
|
||||
if index is None:
|
||||
return [SessionElement(e, page) if isinstance(e, HtmlElement) else e for e in eles if e != '\n']
|
||||
r = SessionElementsList(page)
|
||||
for e in eles:
|
||||
if e != '\n':
|
||||
r.append(SessionElement(e, page) if isinstance(e, HtmlElement) else e)
|
||||
return r
|
||||
|
||||
else:
|
||||
eles_count = len(eles)
|
||||
|
@ -11,6 +11,7 @@ from lxml.html import HtmlElement
|
||||
|
||||
from .._base.base import DrissionElement, BaseElement
|
||||
from .._elements.chromium_element import ChromiumElement
|
||||
from .._functions.elements import SessionElementsList
|
||||
from .._pages.chromium_base import ChromiumBase
|
||||
from .._pages.chromium_frame import ChromiumFrame
|
||||
from .._pages.session_page import SessionPage
|
||||
@ -123,20 +124,20 @@ class SessionElement(DrissionElement):
|
||||
|
||||
def eles(self,
|
||||
locator: Union[Tuple[str, str], str],
|
||||
timeout: float = None) -> List[SessionElement]: ...
|
||||
timeout: float = None) -> SessionElementsList: ...
|
||||
|
||||
def s_ele(self,
|
||||
locator: Union[Tuple[str, str], str] = None,
|
||||
index: int = 1) -> SessionElement: ...
|
||||
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str]) -> List[SessionElement]: ...
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str]) -> SessionElementsList: ...
|
||||
|
||||
def _find_elements(self,
|
||||
locator: Union[Tuple[str, str], str],
|
||||
timeout: float = None,
|
||||
index: Optional[int] = 1,
|
||||
relative: bool = False,
|
||||
raise_err: bool = None) -> Union[SessionElement, List[SessionElement]]: ...
|
||||
raise_err: bool = None) -> Union[SessionElement, SessionElementsList]: ...
|
||||
|
||||
def _get_ele_path(self, mode: str) -> str: ...
|
||||
|
||||
@ -145,4 +146,4 @@ def make_session_ele(html_or_ele: Union[str, SessionElement, SessionPage, Chromi
|
||||
ChromiumBase],
|
||||
loc: Union[str, Tuple[str, str]] = None,
|
||||
index: Optional[int] = 1,
|
||||
method: Optional[str] = None) -> Union[SessionElement, List[SessionElement]]: ...
|
||||
method: Optional[str] = None) -> Union[SessionElement, SessionElementsList]: ...
|
||||
|
@ -10,7 +10,7 @@ from time import perf_counter
|
||||
from .._elements.none_element import NoneElement
|
||||
|
||||
|
||||
class ElementsList(list):
|
||||
class SessionElementsList(list):
|
||||
def __init__(self, page=None):
|
||||
super().__init__()
|
||||
self._page = page
|
||||
@ -18,23 +18,38 @@ class ElementsList(list):
|
||||
self._filter_one = None
|
||||
self._getter = None
|
||||
|
||||
@property
|
||||
def get(self):
|
||||
if self._getter is None:
|
||||
self._getter = Getter(self)
|
||||
return self._getter
|
||||
|
||||
@property
|
||||
def filter(self):
|
||||
if self._filter is None:
|
||||
self._filter = Filter(self)
|
||||
self._filter = SessionFilter(self)
|
||||
return self._filter
|
||||
|
||||
@property
|
||||
def filter_one(self):
|
||||
if self._filter_one is None:
|
||||
self._filter_one = FilterOne(self)
|
||||
self._filter_one = SessionFilterOne(self)
|
||||
return self._filter_one
|
||||
|
||||
|
||||
class ChromiumElementsList(SessionElementsList):
|
||||
|
||||
@property
|
||||
def get(self):
|
||||
if self._getter is None:
|
||||
self._getter = Getter(self)
|
||||
return self._getter
|
||||
def filter(self):
|
||||
if self._filter is None:
|
||||
self._filter = ChromiumFilter(self)
|
||||
return self._filter
|
||||
|
||||
@property
|
||||
def filter_one(self):
|
||||
if self._filter_one is None:
|
||||
self._filter_one = ChromiumFilterOne(self)
|
||||
return self._filter_one
|
||||
|
||||
def search(self, displayed=None, checked=None, selected=None, enabled=None, clickable=None,
|
||||
have_rect=None, have_text=None):
|
||||
@ -48,7 +63,7 @@ class ElementsList(list):
|
||||
:param have_text: 是否含有文本,bool,None为忽略该项
|
||||
:return: 筛选结果
|
||||
"""
|
||||
r = ElementsList(self._page)
|
||||
r = ChromiumElementsList(self._page)
|
||||
for i in self:
|
||||
if ((displayed is not None and (displayed is True and i.states.is_displayed) or (
|
||||
displayed is False and not i.states.is_displayed))
|
||||
@ -65,7 +80,7 @@ class ElementsList(list):
|
||||
or (have_text is not None and (have_text is True and i.raw_text) or (
|
||||
have_text is False and not i.raw_text))):
|
||||
r.append(i)
|
||||
return Filter(r)
|
||||
return ChromiumFilter(r)
|
||||
|
||||
def search_one(self, displayed=None, checked=None, selected=None, enabled=None, clickable=None,
|
||||
have_rect=None, have_text=None):
|
||||
@ -102,10 +117,118 @@ class ElementsList(list):
|
||||
'have_rect': have_rect, 'have_text': have_text})
|
||||
|
||||
|
||||
class BaseFilter(object):
|
||||
class SessionFilterOne(object):
|
||||
def __init__(self, _list):
|
||||
self._list = _list
|
||||
|
||||
def attr(self, name, value, equal=True):
|
||||
"""以是否拥有某个attribute值为条件筛选元素
|
||||
:param name: 属性名称
|
||||
:param value: 属性值
|
||||
:param equal: True表示匹配name值为value值的元素,False表示匹配name值不为value值的
|
||||
:return: 筛选结果
|
||||
"""
|
||||
return self._get_attr(name, value, 'attr', equal=equal)
|
||||
|
||||
def text(self, text, fuzzy=True, contain=True):
|
||||
"""以是否含有指定文本为条件筛选元素
|
||||
:param text: 用于匹配的文本
|
||||
:param fuzzy: 是否模糊匹配
|
||||
:param contain: 是否包含该字符串,False表示不包含
|
||||
:return: 筛选结果
|
||||
"""
|
||||
if contain:
|
||||
for i in self._list:
|
||||
t = i.raw_text
|
||||
if (fuzzy and text in t) or (not fuzzy and text == t):
|
||||
return i
|
||||
else:
|
||||
for i in self._list:
|
||||
t = i.raw_text
|
||||
if (fuzzy and text not in t) or (not fuzzy and text != t):
|
||||
return i
|
||||
return NoneElement(self._list._page, 'text()', args={'text': text, 'fuzzy': fuzzy, 'contain': contain})
|
||||
|
||||
def _get_attr(self, name, value, method, equal=True):
|
||||
"""返回通过某个方法可获得某个值的元素
|
||||
:param name: 属性名称
|
||||
:param value: 属性值
|
||||
:param method: 方法名称
|
||||
:return: 筛选结果
|
||||
"""
|
||||
if equal:
|
||||
for i in self._list:
|
||||
if getattr(i, method)(name) == value:
|
||||
return i
|
||||
else:
|
||||
for i in self._list:
|
||||
if getattr(i, method)(name) != value:
|
||||
return i
|
||||
return NoneElement(self._list._page, f'{method}()', args={'name': name, 'value': value, 'equal': equal})
|
||||
|
||||
|
||||
class SessionFilter(SessionFilterOne):
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self._list)
|
||||
|
||||
def __next__(self):
|
||||
return next(self._list)
|
||||
|
||||
def __len__(self):
|
||||
return len(self._list)
|
||||
|
||||
def __getitem__(self, item):
|
||||
return self._list[item]
|
||||
|
||||
@property
|
||||
def get(self):
|
||||
"""返回用于获取元素属性的对象"""
|
||||
return self._list.get
|
||||
|
||||
def text(self, text, fuzzy=True, contain=True):
|
||||
"""以是否含有指定文本为条件筛选元素
|
||||
:param text: 用于匹配的文本
|
||||
:param fuzzy: 是否模糊匹配
|
||||
:param contain: 是否包含该字符串,False表示不包含
|
||||
:return: 筛选结果
|
||||
"""
|
||||
r = SessionElementsList(self._list._page)
|
||||
if contain:
|
||||
for i in self._list:
|
||||
t = i.raw_text
|
||||
if (fuzzy and text in t) or (not fuzzy and text == t):
|
||||
r.append(i)
|
||||
else:
|
||||
for i in self._list:
|
||||
t = i.raw_text
|
||||
if (fuzzy and text not in t) or (not fuzzy and text != t):
|
||||
r.append(i)
|
||||
self._list = r
|
||||
return self
|
||||
|
||||
def _get_attr(self, name, value, method, equal=True):
|
||||
"""返回通过某个方法可获得某个值的元素
|
||||
:param name: 属性名称
|
||||
:param value: 属性值
|
||||
:param method: 方法名称
|
||||
:return: 筛选结果
|
||||
"""
|
||||
r = SessionElementsList(self._list._page)
|
||||
if equal:
|
||||
for i in self._list:
|
||||
if getattr(i, method)(name) == value:
|
||||
r.append(i)
|
||||
else:
|
||||
for i in self._list:
|
||||
if getattr(i, method)(name) != value:
|
||||
r.append(i)
|
||||
self._list = r
|
||||
return self
|
||||
|
||||
|
||||
class ChromiumFilterOne(SessionFilterOne):
|
||||
|
||||
def displayed(self, equal=True):
|
||||
"""以是否显示为条件筛选元素
|
||||
:param equal: 是否匹配显示的元素,False匹配不显示的
|
||||
@ -166,23 +289,24 @@ class BaseFilter(object):
|
||||
"""
|
||||
return self._get_attr(name, value, 'property', equal=equal)
|
||||
|
||||
def attr(self, name, value, equal=True):
|
||||
"""以是否拥有某个attribute值为条件筛选元素
|
||||
:param name: 属性名称
|
||||
:param value: 属性值
|
||||
:param equal: True表示匹配name值为value值的元素,False表示匹配name值不为value值的
|
||||
:return: 筛选结果
|
||||
"""
|
||||
return self._get_attr(name, value, 'attr', equal=equal)
|
||||
|
||||
def _get_attr(self, name, value, method, equal=True):
|
||||
pass
|
||||
|
||||
def _any_state(self, name, equal=True):
|
||||
pass
|
||||
"""
|
||||
:param name: 状态名称
|
||||
:param equal: 是否是指定状态,False表示否定状态
|
||||
:return: 选中的元素
|
||||
"""
|
||||
if equal:
|
||||
for i in self._list:
|
||||
if getattr(i.states, name):
|
||||
return i
|
||||
else:
|
||||
for i in self._list:
|
||||
if not getattr(i.states, name):
|
||||
return i
|
||||
return NoneElement(self._list._page, f'{name}()', args={'equal': equal})
|
||||
|
||||
|
||||
class Filter(BaseFilter):
|
||||
class ChromiumFilter(ChromiumFilterOne):
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self._list)
|
||||
@ -190,10 +314,11 @@ class Filter(BaseFilter):
|
||||
def __next__(self):
|
||||
return next(self._list)
|
||||
|
||||
@property
|
||||
def get(self):
|
||||
"""返回用于获取元素属性的对象"""
|
||||
return self._list.get
|
||||
def __len__(self):
|
||||
return len(self._list)
|
||||
|
||||
def __getitem__(self, item):
|
||||
return self._list[item]
|
||||
|
||||
@property
|
||||
def search_one(self, displayed=None, checked=None, selected=None, enabled=None, clickable=None,
|
||||
@ -234,7 +359,7 @@ class Filter(BaseFilter):
|
||||
:param contain: 是否包含该字符串,False表示不包含
|
||||
:return: 筛选结果
|
||||
"""
|
||||
r = ElementsList(self._list._page)
|
||||
r = ChromiumElementsList(self._list._page)
|
||||
if contain:
|
||||
for i in self._list:
|
||||
t = i.raw_text
|
||||
@ -255,7 +380,7 @@ class Filter(BaseFilter):
|
||||
:param method: 方法名称
|
||||
:return: 筛选结果
|
||||
"""
|
||||
r = ElementsList(self._list._page)
|
||||
r = ChromiumElementsList(self._list._page)
|
||||
if equal:
|
||||
for i in self._list:
|
||||
if getattr(i, method)(name) == value:
|
||||
@ -273,7 +398,7 @@ class Filter(BaseFilter):
|
||||
:param equal: 是否是指定状态,False表示否定状态
|
||||
:return: 选中的列表
|
||||
"""
|
||||
r = ElementsList(self._list._page)
|
||||
r = ChromiumElementsList(self._list._page)
|
||||
if equal:
|
||||
for i in self._list:
|
||||
if getattr(i.states, name):
|
||||
@ -286,62 +411,6 @@ class Filter(BaseFilter):
|
||||
return self
|
||||
|
||||
|
||||
class FilterOne(BaseFilter):
|
||||
|
||||
def text(self, text, fuzzy=True, contain=True):
|
||||
"""以是否含有指定文本为条件筛选元素
|
||||
:param text: 用于匹配的文本
|
||||
:param fuzzy: 是否模糊匹配
|
||||
:param contain: 是否包含该字符串,False表示不包含
|
||||
:return: 选中的元素
|
||||
"""
|
||||
if contain:
|
||||
for i in self._list:
|
||||
t = i.raw_text
|
||||
if (fuzzy and text in t) or (not fuzzy and text == t):
|
||||
return i
|
||||
else:
|
||||
for i in self._list:
|
||||
t = i.raw_text
|
||||
if (fuzzy and text not in t) or (not fuzzy and text != t):
|
||||
return i
|
||||
return NoneElement(self._list._page, 'text()', args={'text': text, 'fuzzy': fuzzy, 'contain': contain})
|
||||
|
||||
def _get_attr(self, name, value, method, equal=True):
|
||||
"""返回通过某个方法可获得某个值的元素
|
||||
:param name: 属性名称
|
||||
:param value: 属性值
|
||||
:param method: 方法名称
|
||||
:param equal: 是否是指定状态,False表示否定状态
|
||||
:return: 选中的元素
|
||||
"""
|
||||
if equal:
|
||||
for i in self._list:
|
||||
if getattr(i, method)(name) == value:
|
||||
return i
|
||||
else:
|
||||
for i in self._list:
|
||||
if getattr(i, method)(name) != value:
|
||||
return i
|
||||
return NoneElement(self._list._page, f'{method}()', args={'name': name, 'value': value})
|
||||
|
||||
def _any_state(self, name, equal=True):
|
||||
"""
|
||||
:param name: 状态名称
|
||||
:param equal: 是否是指定状态,False表示否定状态
|
||||
:return: 选中的元素
|
||||
"""
|
||||
if equal:
|
||||
for i in self._list:
|
||||
if getattr(i.states, name):
|
||||
return i
|
||||
else:
|
||||
for i in self._list:
|
||||
if not getattr(i.states, name):
|
||||
return i
|
||||
return NoneElement(self._list._page, f'{name}()', args={'equal': equal})
|
||||
|
||||
|
||||
class Getter(object):
|
||||
def __init__(self, _list):
|
||||
self._list = _list
|
||||
|
@ -9,6 +9,7 @@ from typing import Union, List, Optional, Iterable
|
||||
|
||||
from .._base.base import BaseParser
|
||||
from .._elements.chromium_element import ChromiumElement
|
||||
from .._elements.session_element import SessionElement
|
||||
|
||||
|
||||
def get_eles(locators: Union[List[str], tuple],
|
||||
@ -18,21 +19,36 @@ def get_eles(locators: Union[List[str], tuple],
|
||||
timeout: float = 10) -> dict: ...
|
||||
|
||||
|
||||
class ElementsList(list):
|
||||
class SessionElementsList(list):
|
||||
_page = ...
|
||||
_filter: Optional[Filter] = ...
|
||||
_filter_one: Optional[FilterOne] = ...
|
||||
_filter: Optional[SessionFilter] = ...
|
||||
_filter_one: Optional[SessionFilterOne] = ...
|
||||
_getter: Optional[Getter] = ...
|
||||
|
||||
@property
|
||||
def filter(self) -> Filter: ...
|
||||
|
||||
@property
|
||||
def filter_one(self) -> FilterOne: ...
|
||||
def __init__(self, page=None): ...
|
||||
|
||||
@property
|
||||
def get(self) -> Getter: ...
|
||||
|
||||
@property
|
||||
def filter(self) -> SessionFilter: ...
|
||||
|
||||
@property
|
||||
def filter_one(self) -> SessionFilterOne: ...
|
||||
|
||||
def __next__(self) -> SessionElement: ...
|
||||
|
||||
|
||||
class ChromiumElementsList(SessionElementsList):
|
||||
_filter: Optional[ChromiumFilter] = ...
|
||||
_filter_one: Optional[ChromiumFilterOne] = ...
|
||||
|
||||
@property
|
||||
def filter(self) -> ChromiumFilter: ...
|
||||
|
||||
@property
|
||||
def filter_one(self) -> ChromiumFilterOne: ...
|
||||
|
||||
def search(self,
|
||||
displayed: Optional[bool] = None,
|
||||
checked: Optional[bool] = None,
|
||||
@ -40,7 +56,7 @@ class ElementsList(list):
|
||||
enabled: Optional[bool] = None,
|
||||
clickable: Optional[bool] = None,
|
||||
have_rect: Optional[bool] = None,
|
||||
have_text: Optional[bool] = None) -> Filter: ...
|
||||
have_text: Optional[bool] = None) -> ChromiumFilter: ...
|
||||
|
||||
def search_one(self,
|
||||
displayed: Optional[bool] = None,
|
||||
@ -54,105 +70,50 @@ class ElementsList(list):
|
||||
def __next__(self) -> ChromiumElement: ...
|
||||
|
||||
|
||||
class BaseFilter(object):
|
||||
_list: ElementsList = ...
|
||||
class SessionFilterOne(object):
|
||||
_list: SessionElementsList = ...
|
||||
|
||||
def __init__(self, _list: ElementsList): ...
|
||||
def __init__(self, _list: SessionElementsList, index: int = 1): ...
|
||||
|
||||
def displayed(self, equal: bool = True): ...
|
||||
def attr(self, name: str, value: str, equal: bool = True) -> SessionElement: ...
|
||||
|
||||
def checked(self, equal: bool = True): ...
|
||||
|
||||
def selected(self, equal: bool = True): ...
|
||||
|
||||
def enabled(self, equal: bool = True): ...
|
||||
|
||||
def clickable(self, equal: bool = True): ...
|
||||
|
||||
def have_rect(self, equal: bool = True): ...
|
||||
|
||||
def style(self, name: str, value: str, equal: bool = True): ...
|
||||
|
||||
def property(self,
|
||||
name: str,
|
||||
value: str,
|
||||
equal: bool = True): ...
|
||||
|
||||
def attr(self, name: str, value: str, equal: bool = True): ...
|
||||
def text(self, text: str, fuzzy: bool = True, contain: bool = True) -> SessionElement: ...
|
||||
|
||||
def _get_attr(self,
|
||||
name: str,
|
||||
value: str,
|
||||
method: str,
|
||||
equal: bool = True): ...
|
||||
|
||||
def _any_state(self, name: str, equal: bool = True): ...
|
||||
equal: bool = True) -> SessionElement: ...
|
||||
|
||||
|
||||
class Filter:
|
||||
_list: ElementsList = ...
|
||||
class SessionFilter(SessionFilterOne):
|
||||
|
||||
def __init__(self, _list: ElementsList): ...
|
||||
def __iter__(self) -> Iterable[SessionElement]: ...
|
||||
|
||||
def __iter__(self) -> Iterable[ChromiumElement]: ...
|
||||
def __next__(self) -> SessionElement: ...
|
||||
|
||||
def __next__(self) -> ChromiumElement: ...
|
||||
def __len__(self) -> int: ...
|
||||
|
||||
def __getitem__(self, item: int) -> SessionElement: ...
|
||||
|
||||
@property
|
||||
def get(self) -> Getter: ...
|
||||
|
||||
def displayed(self, equal: bool = True) -> Filter: ...
|
||||
def attr(self, name: str, value: str, equal: bool = True) -> SessionFilter: ...
|
||||
|
||||
def checked(self, equal: bool = True) -> Filter: ...
|
||||
|
||||
def selected(self, equal: bool = True) -> Filter: ...
|
||||
|
||||
def enabled(self, equal: bool = True) -> Filter: ...
|
||||
|
||||
def clickable(self, equal: bool = True) -> Filter: ...
|
||||
|
||||
def have_rect(self, equal: bool = True) -> Filter: ...
|
||||
|
||||
def style(self, name: str, value: str, equal: bool = True) -> Filter: ...
|
||||
|
||||
def property(self,
|
||||
name: str,
|
||||
value: str, equal: bool = True) -> Filter: ...
|
||||
|
||||
def attr(self, name: str, value: str, equal: bool = True) -> Filter: ...
|
||||
|
||||
def text(self, text: str, fuzzy: bool = True, contain: bool = True) -> Filter: ...
|
||||
|
||||
def search(self,
|
||||
displayed: Optional[bool] = None,
|
||||
checked: Optional[bool] = None,
|
||||
selected: Optional[bool] = None,
|
||||
enabled: Optional[bool] = None,
|
||||
clickable: Optional[bool] = None,
|
||||
have_rect: Optional[bool] = None,
|
||||
have_text: Optional[bool] = None) -> Filter: ...
|
||||
|
||||
def search_one(self,
|
||||
displayed: Optional[bool] = None,
|
||||
checked: Optional[bool] = None,
|
||||
selected: Optional[bool] = None,
|
||||
enabled: Optional[bool] = None,
|
||||
clickable: Optional[bool] = None,
|
||||
have_rect: Optional[bool] = None,
|
||||
have_text: Optional[bool] = None) -> ChromiumElement: ...
|
||||
def text(self, text: str, fuzzy: bool = True, contain: bool = True) -> SessionFilter: ...
|
||||
|
||||
def _get_attr(self,
|
||||
name: str,
|
||||
value: str,
|
||||
method: str, equal: bool = True) -> Filter: ...
|
||||
|
||||
def _any_state(self, name: str, equal: bool = True) -> Filter: ...
|
||||
method: str,
|
||||
equal: bool = True) -> SessionFilter: ...
|
||||
|
||||
|
||||
class FilterOne(BaseFilter):
|
||||
_list: ElementsList = ...
|
||||
class ChromiumFilterOne(SessionFilterOne):
|
||||
_list: ChromiumElementsList = ...
|
||||
|
||||
def __init__(self, _list: ElementsList): ...
|
||||
def __init__(self, _list: ChromiumElementsList): ...
|
||||
|
||||
def displayed(self, equal: bool = True) -> ChromiumElement: ...
|
||||
|
||||
@ -184,10 +145,71 @@ class FilterOne(BaseFilter):
|
||||
def _any_state(self, name: str, equal: bool = True) -> ChromiumElement: ...
|
||||
|
||||
|
||||
class Getter(object):
|
||||
_list: ElementsList = ...
|
||||
class ChromiumFilter(ChromiumFilterOne):
|
||||
|
||||
def __init__(self, _list: ElementsList): ...
|
||||
def __iter__(self) -> Iterable[ChromiumElement]: ...
|
||||
|
||||
def __next__(self) -> ChromiumElement: ...
|
||||
|
||||
def __len__(self) -> int: ...
|
||||
|
||||
def __getitem__(self, item: int) -> ChromiumElement: ...
|
||||
|
||||
@property
|
||||
def get(self) -> Getter: ...
|
||||
|
||||
def displayed(self, equal: bool = True) -> ChromiumFilter: ...
|
||||
|
||||
def checked(self, equal: bool = True) -> ChromiumFilter: ...
|
||||
|
||||
def selected(self, equal: bool = True) -> ChromiumFilter: ...
|
||||
|
||||
def enabled(self, equal: bool = True) -> ChromiumFilter: ...
|
||||
|
||||
def clickable(self, equal: bool = True) -> ChromiumFilter: ...
|
||||
|
||||
def have_rect(self, equal: bool = True) -> ChromiumFilter: ...
|
||||
|
||||
def style(self, name: str, value: str, equal: bool = True) -> ChromiumFilter: ...
|
||||
|
||||
def property(self,
|
||||
name: str,
|
||||
value: str, equal: bool = True) -> ChromiumFilter: ...
|
||||
|
||||
def attr(self, name: str, value: str, equal: bool = True) -> ChromiumFilter: ...
|
||||
|
||||
def text(self, text: str, fuzzy: bool = True, contain: bool = True) -> ChromiumFilter: ...
|
||||
|
||||
def search(self,
|
||||
displayed: Optional[bool] = None,
|
||||
checked: Optional[bool] = None,
|
||||
selected: Optional[bool] = None,
|
||||
enabled: Optional[bool] = None,
|
||||
clickable: Optional[bool] = None,
|
||||
have_rect: Optional[bool] = None,
|
||||
have_text: Optional[bool] = None) -> ChromiumFilter: ...
|
||||
|
||||
def search_one(self,
|
||||
displayed: Optional[bool] = None,
|
||||
checked: Optional[bool] = None,
|
||||
selected: Optional[bool] = None,
|
||||
enabled: Optional[bool] = None,
|
||||
clickable: Optional[bool] = None,
|
||||
have_rect: Optional[bool] = None,
|
||||
have_text: Optional[bool] = None) -> ChromiumElement: ...
|
||||
|
||||
def _get_attr(self,
|
||||
name: str,
|
||||
value: str,
|
||||
method: str, equal: bool = True) -> ChromiumFilter: ...
|
||||
|
||||
def _any_state(self, name: str, equal: bool = True) -> ChromiumFilter: ...
|
||||
|
||||
|
||||
class Getter(object):
|
||||
_list: SessionElementsList = ...
|
||||
|
||||
def __init__(self, _list: SessionElementsList): ...
|
||||
|
||||
def links(self) -> List[str]: ...
|
||||
|
||||
|
@ -14,7 +14,7 @@ from .._base.browser import Browser
|
||||
from .._base.driver import Driver
|
||||
from .._elements.chromium_element import ChromiumElement
|
||||
from .._elements.session_element import SessionElement
|
||||
from .._functions.elements import ElementsList
|
||||
from .._functions.elements import SessionElementsList, ChromiumElementsList
|
||||
from .._pages.chromium_frame import ChromiumFrame
|
||||
from .._pages.chromium_page import ChromiumPage
|
||||
from .._units.actions import Actions
|
||||
@ -188,21 +188,20 @@ class ChromiumBase(BasePage):
|
||||
|
||||
def eles(self,
|
||||
locator: Union[Tuple[str, str], str],
|
||||
timeout: float = None) -> ElementsList: ...
|
||||
timeout: float = None) -> ChromiumElementsList: ...
|
||||
|
||||
def s_ele(self,
|
||||
locator: Union[Tuple[str, str], str] = None,
|
||||
index: int = 1) -> SessionElement: ...
|
||||
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str]) -> List[SessionElement]: ...
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str]) -> SessionElementsList: ...
|
||||
|
||||
def _find_elements(self,
|
||||
locator: Union[Tuple[str, str], str, ChromiumElement, ChromiumFrame],
|
||||
timeout: float = None,
|
||||
index: Optional[int] = 1,
|
||||
relative: bool = False,
|
||||
raise_err: bool = None) \
|
||||
-> Union[ChromiumElement, ChromiumFrame, List[Union[ChromiumElement, ChromiumFrame]]]: ...
|
||||
raise_err: bool = None) -> Union[ChromiumElement, ChromiumFrame, ChromiumElementsList]: ...
|
||||
|
||||
def refresh(self, ignore_cache: bool = False) -> None: ...
|
||||
|
||||
|
@ -10,9 +10,10 @@ from typing import Union, Tuple, List, Any, Optional
|
||||
|
||||
from .chromium_base import ChromiumBase
|
||||
from .chromium_page import ChromiumPage
|
||||
from .chromium_tab import ChromiumTab, WebPageTab
|
||||
from .chromium_tab import ChromiumTab
|
||||
from .web_page import WebPage
|
||||
from .._elements.chromium_element import ChromiumElement
|
||||
from .._functions.elements import ChromiumElementsList
|
||||
from .._units.listener import FrameListener
|
||||
from .._units.rect import FrameRect
|
||||
from .._units.scroller import FrameScroller
|
||||
@ -214,7 +215,6 @@ class ChromiumFrame(ChromiumBase):
|
||||
timeout: float = None,
|
||||
index: Optional[int] = 1,
|
||||
relative: bool = False,
|
||||
raise_err: bool = None) \
|
||||
-> Union[ChromiumElement, ChromiumFrame, None, List[Union[ChromiumElement, ChromiumFrame]]]: ...
|
||||
raise_err: bool = None) -> Union[ChromiumElement, ChromiumFrame, None, ChromiumElementsList]: ...
|
||||
|
||||
def _is_inner_frame(self) -> bool: ...
|
||||
|
@ -6,7 +6,7 @@
|
||||
@License : BSD 3-Clause.
|
||||
"""
|
||||
from pathlib import Path
|
||||
from typing import Union, Tuple, Any, List, Optional
|
||||
from typing import Union, Tuple, Any, Optional
|
||||
|
||||
from requests import Session, Response
|
||||
|
||||
@ -18,6 +18,7 @@ from .web_page import WebPage
|
||||
from .._base.browser import Browser
|
||||
from .._elements.chromium_element import ChromiumElement
|
||||
from .._elements.session_element import SessionElement
|
||||
from .._functions.elements import SessionElementsList, ChromiumElementsList
|
||||
from .._units.rect import TabRect
|
||||
from .._units.setter import TabSetter, WebPageTabSetter
|
||||
from .._units.waiter import TabWaiter
|
||||
@ -150,13 +151,13 @@ class WebPageTab(SessionPage, ChromiumTab):
|
||||
|
||||
def eles(self,
|
||||
locator: Union[Tuple[str, str], str],
|
||||
timeout: float = None) -> List[Union[ChromiumElement, SessionElement]]: ...
|
||||
timeout: float = None) -> Union[SessionElementsList, ChromiumElementsList]: ...
|
||||
|
||||
def s_ele(self,
|
||||
locator: Union[Tuple[str, str], str] = None,
|
||||
index: int = 1) -> SessionElement: ...
|
||||
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str]) -> List[SessionElement]: ...
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str]) -> SessionElementsList: ...
|
||||
|
||||
def change_mode(self, mode: str = None, go: bool = True, copy_cookies: bool = True) -> None: ...
|
||||
|
||||
@ -199,5 +200,4 @@ class WebPageTab(SessionPage, ChromiumTab):
|
||||
index: Optional[int] = 1,
|
||||
relative: bool = False,
|
||||
raise_err: bool = None) \
|
||||
-> Union[ChromiumElement, SessionElement, ChromiumFrame, List[SessionElement], List[
|
||||
Union[ChromiumElement, ChromiumFrame]]]: ...
|
||||
-> Union[ChromiumElement, SessionElement, ChromiumFrame, SessionElementsList, ChromiumElementsList]: ...
|
||||
|
@ -6,7 +6,7 @@
|
||||
@License : BSD 3-Clause.
|
||||
"""
|
||||
from pathlib import Path
|
||||
from typing import Any, Union, Tuple, List, Optional
|
||||
from typing import Any, Union, Tuple, Optional
|
||||
|
||||
from requests import Session, Response
|
||||
from requests.structures import CaseInsensitiveDict
|
||||
@ -14,6 +14,7 @@ from requests.structures import CaseInsensitiveDict
|
||||
from .._base.base import BasePage
|
||||
from .._configs.session_options import SessionOptions
|
||||
from .._elements.session_element import SessionElement
|
||||
from .._functions.elements import SessionElementsList
|
||||
from .._units.setter import SessionPageSetter
|
||||
|
||||
|
||||
@ -97,13 +98,13 @@ class SessionPage(BasePage):
|
||||
|
||||
def eles(self,
|
||||
locator: Union[Tuple[str, str], str],
|
||||
timeout: float = None) -> List[SessionElement]: ...
|
||||
timeout: float = None) -> SessionElementsList: ...
|
||||
|
||||
def s_ele(self,
|
||||
locator: Union[Tuple[str, str], str, SessionElement] = None,
|
||||
index: int = 1) -> SessionElement: ...
|
||||
|
||||
def s_eles(self, loc: Union[Tuple[str, str], str]) -> List[SessionElement]: ...
|
||||
def s_eles(self, loc: Union[Tuple[str, str], str]) -> SessionElementsList: ...
|
||||
|
||||
def _find_elements(self,
|
||||
locator: Union[Tuple[str, str], str, SessionElement],
|
||||
@ -111,7 +112,7 @@ class SessionPage(BasePage):
|
||||
index: Optional[int] = 1,
|
||||
relative: bool = True,
|
||||
raise_err: bool = None) \
|
||||
-> Union[SessionElement, List[SessionElement]]: ...
|
||||
-> Union[SessionElement, SessionElementsList]: ...
|
||||
|
||||
def cookies(self,
|
||||
as_dict: bool = False,
|
||||
|
@ -19,7 +19,7 @@ from .._configs.chromium_options import ChromiumOptions
|
||||
from .._configs.session_options import SessionOptions
|
||||
from .._elements.chromium_element import ChromiumElement
|
||||
from .._elements.session_element import SessionElement
|
||||
from .._functions.elements import ElementsList
|
||||
from .._functions.elements import SessionElementsList, ChromiumElementsList
|
||||
from .._units.setter import WebPageSetter
|
||||
|
||||
|
||||
@ -109,13 +109,13 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
|
||||
def eles(self,
|
||||
locator: Union[Tuple[str, str], str],
|
||||
timeout: float = None) -> Union[ElementsList, List[Union[ChromiumElement, SessionElement]]]: ...
|
||||
timeout: float = None) -> Union[SessionElementsList, ChromiumElementsList]: ...
|
||||
|
||||
def s_ele(self,
|
||||
locator: Union[Tuple[str, str], str] = None,
|
||||
index: int = 1) -> SessionElement: ...
|
||||
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str]) -> List[SessionElement]: ...
|
||||
def s_eles(self, locator: Union[Tuple[str, str], str]) -> SessionElementsList: ...
|
||||
|
||||
def change_mode(self, mode: str = None, go: bool = True, copy_cookies: bool = True) -> None: ...
|
||||
|
||||
@ -186,8 +186,7 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
index: Optional[int] = 1,
|
||||
relative: bool = False,
|
||||
raise_err: bool = None) \
|
||||
-> Union[ChromiumElement, SessionElement, ChromiumFrame, List[SessionElement],
|
||||
List[Union[ChromiumElement, ChromiumFrame]]]: ...
|
||||
-> Union[ChromiumElement, SessionElement, ChromiumFrame, SessionElementsList, ChromiumElementsList]: ...
|
||||
|
||||
def _set_start_options(self,
|
||||
dr_opt: Union[Driver, bool, None],
|
||||
|
Loading…
x
Reference in New Issue
Block a user