删除run_async_js()timeout参数

This commit is contained in:
g1879 2023-12-27 23:57:53 +08:00
parent 655895c560
commit a75cb3a0b3
2 changed files with 5 additions and 8 deletions

View File

@ -364,7 +364,7 @@ class ChromiumElement(DrissionElement):
def run_js(self, script, *args, as_expr=False, timeout=None): def run_js(self, script, *args, as_expr=False, timeout=None):
"""对本元素执行javascript代码 """对本元素执行javascript代码
:param script: js文本 :param script: js文本文本中用this表示本元素
:param args: 参数按顺序在js文本中对应arguments[0]arguments[1]... :param args: 参数按顺序在js文本中对应arguments[0]arguments[1]...
:param as_expr: 是否作为表达式运行为True时args无效 :param as_expr: 是否作为表达式运行为True时args无效
:param timeout: js超时时间为None则使用页面timeouts.script设置 :param timeout: js超时时间为None则使用页面timeouts.script设置
@ -372,17 +372,14 @@ class ChromiumElement(DrissionElement):
""" """
return run_js(self, script, as_expr, self.page.timeouts.script if timeout is None else timeout, args) return run_js(self, script, as_expr, self.page.timeouts.script if timeout is None else timeout, args)
def run_async_js(self, script, *args, as_expr=False, timeout=None): def run_async_js(self, script, *args, as_expr=False):
"""以异步方式对本元素执行javascript代码 """以异步方式对本元素执行javascript代码
:param script: js文本 :param script: js文本文本中用this表示本元素
:param args: 参数按顺序在js文本中对应arguments[0]arguments[1]... :param args: 参数按顺序在js文本中对应arguments[0]arguments[1]...
:param as_expr: 是否作为表达式运行为True时args无效 :param as_expr: 是否作为表达式运行为True时args无效
:param timeout: js超时时间为None则使用页面timeouts.script设置
:return: None :return: None
""" """
from threading import Thread run_js(self, script, as_expr, 0, args)
Thread(target=run_js, args=(self, script, as_expr, self.page.timeouts.script if timeout is None else timeout,
args, True)).start()
def ele(self, loc_or_str, timeout=None): def ele(self, loc_or_str, timeout=None):
"""返回当前元素下级符合条件的第一个元素、属性或节点文本 """返回当前元素下级符合条件的第一个元素、属性或节点文本

View File

@ -167,7 +167,7 @@ class ChromiumElement(DrissionElement):
def run_js(self, script: str, *args, as_expr: bool = False, timeout: float = None) -> Any: ... def run_js(self, script: str, *args, as_expr: bool = False, timeout: float = None) -> Any: ...
def run_async_js(self, script: str, *args, as_expr: bool = False, timeout: float = None) -> None: ... def run_async_js(self, script: str, *args, as_expr: bool = False) -> None: ...
def ele(self, def ele(self,
loc_or_str: Union[Tuple[str, str], str], loc_or_str: Union[Tuple[str, str], str],