fix_count改为fit_count;click()by_js默认None

This commit is contained in:
g1879 2023-11-21 16:35:39 +08:00
parent 1a0d3c8029
commit 9d51af46ab
4 changed files with 10 additions and 10 deletions

View File

@ -17,7 +17,7 @@ class Clicker(object):
"""
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点击
:param by_js: 是否用js点击为None时先用模拟点击遇到遮挡改用js为True时直接用js点击为False时只用模拟点击
@ -27,7 +27,7 @@ class Clicker(object):
"""
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点击
:param by_js: 是否用js点击为None时先用模拟点击遇到遮挡改用js为True时直接用js点击为False时只用模拟点击
:param timeout: 模拟点击的超时时间等待元素可见可用进入视口
@ -55,7 +55,7 @@ class Clicker(object):
rect = self._ele.states.has_rect
sleep(.001)
if wait_stop:
if wait_stop and rect:
self._ele.wait.stop_moving(timeout=end_time - perf_counter())
if rect:
self._ele.scroll.to_see()

View File

@ -12,9 +12,9 @@ class Clicker(object):
def __init__(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: ...

View File

@ -87,12 +87,12 @@ class NetworkListener(object):
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 timeout: 超时时间为None无限等待
:param fix_count: 是否必须满足总数要求发生超时为True返回False为False返回已捕捉到的数据包
:return: count为1时返回数据包对象大于1时返回列表超时且fix_count为True时返回False
:param fit_count: 是否必须满足总数要求发生超时为True返回False为False返回已捕捉到的数据包
:return: count为1时返回数据包对象大于1时返回列表超时且fit_count为True时返回False
"""
if not self.listening:
raise RuntimeError('监听未启动或已暂停。')
@ -112,7 +112,7 @@ class NetworkListener(object):
break
if fail:
if fix_count or not self._caught.qsize():
if fit_count or not self._caught.qsize():
return False
else:
return [self._caught.get_nowait() for _ in range(self._caught.qsize())]

View File

@ -37,7 +37,7 @@ class NetworkListener(object):
def go_on(self) -> 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
def results(self) -> Union[DataPacket, Dict[str, List[DataPacket]], False]: ...