mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
fix_count改为fit_count;click()by_js默认None
This commit is contained in:
parent
1a0d3c8029
commit
9d51af46ab
@ -17,7 +17,7 @@ class Clicker(object):
|
|||||||
"""
|
"""
|
||||||
self._ele = ele
|
self._ele = ele
|
||||||
|
|
||||||
def __call__(self, by_js=False, timeout=2, wait_stop=True):
|
def __call__(self, by_js=None, timeout=1.5, wait_stop=True):
|
||||||
"""点击元素
|
"""点击元素
|
||||||
如果遇到遮挡,可选择是否用js点击
|
如果遇到遮挡,可选择是否用js点击
|
||||||
:param by_js: 是否用js点击,为None时先用模拟点击,遇到遮挡改用js,为True时直接用js点击,为False时只用模拟点击
|
:param by_js: 是否用js点击,为None时先用模拟点击,遇到遮挡改用js,为True时直接用js点击,为False时只用模拟点击
|
||||||
@ -27,7 +27,7 @@ class Clicker(object):
|
|||||||
"""
|
"""
|
||||||
return self.left(by_js, timeout, wait_stop)
|
return self.left(by_js, timeout, wait_stop)
|
||||||
|
|
||||||
def left(self, by_js=False, timeout=2, wait_stop=True):
|
def left(self, by_js=None, timeout=1.5, wait_stop=True):
|
||||||
"""点击元素,可选择是否用js点击
|
"""点击元素,可选择是否用js点击
|
||||||
:param by_js: 是否用js点击,为None时先用模拟点击,遇到遮挡改用js,为True时直接用js点击,为False时只用模拟点击
|
:param by_js: 是否用js点击,为None时先用模拟点击,遇到遮挡改用js,为True时直接用js点击,为False时只用模拟点击
|
||||||
:param timeout: 模拟点击的超时时间,等待元素可见、可用、进入视口
|
:param timeout: 模拟点击的超时时间,等待元素可见、可用、进入视口
|
||||||
@ -55,7 +55,7 @@ class Clicker(object):
|
|||||||
rect = self._ele.states.has_rect
|
rect = self._ele.states.has_rect
|
||||||
sleep(.001)
|
sleep(.001)
|
||||||
|
|
||||||
if wait_stop:
|
if wait_stop and rect:
|
||||||
self._ele.wait.stop_moving(timeout=end_time - perf_counter())
|
self._ele.wait.stop_moving(timeout=end_time - perf_counter())
|
||||||
if rect:
|
if rect:
|
||||||
self._ele.scroll.to_see()
|
self._ele.scroll.to_see()
|
||||||
|
@ -12,9 +12,9 @@ class Clicker(object):
|
|||||||
def __init__(self, ele: ChromiumElement):
|
def __init__(self, ele: ChromiumElement):
|
||||||
self._ele: ChromiumElement = ...
|
self._ele: ChromiumElement = ...
|
||||||
|
|
||||||
def __call__(self, by_js: Union[None, bool] = False, timeout: float = 2, wait_stop: bool = True) -> bool: ...
|
def __call__(self, by_js: Union[None, bool] = None, timeout: float = 1.5, wait_stop: bool = True) -> bool: ...
|
||||||
|
|
||||||
def left(self, by_js: Union[None, bool] = False, timeout: float = 2, wait_stop: bool = True) -> bool: ...
|
def left(self, by_js: Union[None, bool] = None, timeout: float = 1.5, wait_stop: bool = True) -> bool: ...
|
||||||
|
|
||||||
def right(self) -> None: ...
|
def right(self) -> None: ...
|
||||||
|
|
||||||
|
@ -87,12 +87,12 @@ class NetworkListener(object):
|
|||||||
|
|
||||||
self._set_callback()
|
self._set_callback()
|
||||||
|
|
||||||
def wait(self, count=1, timeout=None, fix_count=True):
|
def wait(self, count=1, timeout=None, fit_count=True):
|
||||||
"""等待符合要求的数据包到达指定数量
|
"""等待符合要求的数据包到达指定数量
|
||||||
:param count: 需要捕捉的数据包数量
|
:param count: 需要捕捉的数据包数量
|
||||||
:param timeout: 超时时间,为None无限等待
|
:param timeout: 超时时间,为None无限等待
|
||||||
:param fix_count: 是否必须满足总数要求,发生超时,为True返回False,为False返回已捕捉到的数据包
|
:param fit_count: 是否必须满足总数要求,发生超时,为True返回False,为False返回已捕捉到的数据包
|
||||||
:return: count为1时返回数据包对象,大于1时返回列表,超时且fix_count为True时返回False
|
:return: count为1时返回数据包对象,大于1时返回列表,超时且fit_count为True时返回False
|
||||||
"""
|
"""
|
||||||
if not self.listening:
|
if not self.listening:
|
||||||
raise RuntimeError('监听未启动或已暂停。')
|
raise RuntimeError('监听未启动或已暂停。')
|
||||||
@ -112,7 +112,7 @@ class NetworkListener(object):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if fail:
|
if fail:
|
||||||
if fix_count or not self._caught.qsize():
|
if fit_count or not self._caught.qsize():
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return [self._caught.get_nowait() for _ in range(self._caught.qsize())]
|
return [self._caught.get_nowait() for _ in range(self._caught.qsize())]
|
||||||
|
@ -37,7 +37,7 @@ class NetworkListener(object):
|
|||||||
def go_on(self) -> None: ...
|
def go_on(self) -> None: ...
|
||||||
|
|
||||||
def wait(self, count: int = 1, timeout: float = None,
|
def wait(self, count: int = 1, timeout: float = None,
|
||||||
fix_count: bool = True) -> Union[List[DataPacket], DataPacket, None]: ...
|
fit_count: bool = True) -> Union[List[DataPacket], DataPacket, None]: ...
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def results(self) -> Union[DataPacket, Dict[str, List[DataPacket]], False]: ...
|
def results(self) -> Union[DataPacket, Dict[str, List[DataPacket]], False]: ...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user