等待方法修改(+)

ele_delete()改为ele_deleted()、ele_load()改为ele_loaded()、delete()改为deleted()、disabled_or_delete()改为disabled_or_deleted()
This commit is contained in:
g1879 2023-12-18 18:51:58 +08:00
parent 13cb1d7f53
commit 8e3e0750ce
2 changed files with 10 additions and 11 deletions

View File

@ -19,7 +19,7 @@ class BaseWaiter(object):
"""
sleep(second)
def ele_delete(self, loc_or_ele, timeout=None, raise_err=None):
def ele_deleted(self, loc_or_ele, timeout=None, raise_err=None):
"""等待元素从DOM中删除
:param loc_or_ele: 要等待的元素可以是已有元素定位符
:param timeout: 超时时间默认读取页面超时时间
@ -27,7 +27,7 @@ class BaseWaiter(object):
:return: 是否等待成功
"""
ele = self._driver._ele(loc_or_ele, raise_err=False, timeout=0)
return ele.wait.delete(timeout, raise_err=raise_err) if ele else True
return ele.wait.deleted(timeout, raise_err=raise_err) if ele else True
def ele_display(self, loc_or_ele, timeout=None, raise_err=None):
"""等待元素变成显示状态
@ -49,7 +49,7 @@ class BaseWaiter(object):
ele = self._driver._ele(loc_or_ele, raise_err=False, timeout=0)
return ele.wait.hidden(timeout, raise_err=raise_err)
def ele_load(self, loc, timeout=None, raise_err=None):
def ele_loaded(self, loc, timeout=None, raise_err=None):
"""等待元素加载到DOM
:param loc: 要等待的元素输入定位符
:param timeout: 超时时间默认读取页面超时时间
@ -290,7 +290,7 @@ class ElementWaiter(object):
"""
sleep(second)
def delete(self, timeout=None, raise_err=None):
def deleted(self, timeout=None, raise_err=None):
"""等待元素从dom删除
:param timeout: 超时时间为None使用元素所在页面timeout属性
:param raise_err: 等待失败时是否报错为None时根据Settings设置
@ -346,7 +346,7 @@ class ElementWaiter(object):
"""
return self._wait_state('is_enabled', False, timeout, raise_err)
def disabled_or_delete(self, timeout=None, raise_err=None):
def disabled_or_deleted(self, timeout=None, raise_err=None):
"""等待当前元素变成不可用或从DOM移除
:param timeout: 超时时间为None使用元素所在页面timeout属性
:param raise_err: 等待失败时是否报错为None时根据Settings设置

View File

@ -3,10 +3,9 @@
@Author : g1879
@Contact : g1879@qq.com
"""
from typing import Union, List
from typing import Union
from .downloader import DownloadMission
from .listener import DataPacket
from .._elements.chromium_element import ChromiumElement
from .._pages.chromium_base import ChromiumBase
from .._pages.chromium_frame import ChromiumFrame
@ -19,7 +18,7 @@ class BaseWaiter(object):
def __call__(self, second: float) -> None: ...
def ele_delete(self, loc_or_ele: Union[str, tuple, ChromiumElement], timeout: float = None,
def ele_deleted(self, loc_or_ele: Union[str, tuple, ChromiumElement], timeout: float = None,
raise_err: bool = None) -> bool: ...
def ele_display(self, loc_or_ele: Union[str, tuple, ChromiumElement], timeout: float = None,
@ -28,7 +27,7 @@ class BaseWaiter(object):
def ele_hidden(self, loc_or_ele: Union[str, tuple, ChromiumElement], timeout: float = None,
raise_err: bool = None) -> bool: ...
def ele_load(self, loc: Union[str, tuple], timeout: float = None,
def ele_loaded(self, loc: Union[str, tuple], timeout: float = None,
raise_err: bool = None) -> Union[bool, ChromiumElement]: ...
def _loading(self, timeout: float = None, start: bool = True, gap: float = .01, raise_err: bool = None) -> bool: ...
@ -73,7 +72,7 @@ class ElementWaiter(object):
def __call__(self, second: float) -> None: ...
def delete(self, timeout: float = None, raise_err: bool = None) -> bool: ...
def deleted(self, timeout: float = None, raise_err: bool = None) -> bool: ...
def display(self, timeout: float = None, raise_err: bool = None) -> bool: ...
@ -87,7 +86,7 @@ class ElementWaiter(object):
def disabled(self, timeout: float = None, raise_err: bool = None) -> bool: ...
def disabled_or_delete(self, timeout: float = None, raise_err: bool = None) -> bool: ...
def disabled_or_deleted(self, timeout: float = None, raise_err: bool = None) -> bool: ...
def stop_moving(self, gap: float = .1, timeout: float = None, raise_err: bool = None) -> bool: ...