mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
调整run_js()参数顺序
This commit is contained in:
parent
5b78521bbe
commit
e8b22de2e3
@ -360,30 +360,30 @@ class ChromiumBase(BasePage):
|
||||
self.wait.load_complete()
|
||||
return self.run_cdp(cmd, **cmd_args)
|
||||
|
||||
def run_js(self, script, as_expr=False, *args):
|
||||
def run_js(self, script, *args, as_expr=False):
|
||||
"""运行javascript代码
|
||||
:param script: js文本
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:param args: 参数,按顺序在js文本中对应argument[0]、argument[1]...
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:return: 运行的结果
|
||||
"""
|
||||
return run_js(self, script, as_expr, self.timeouts.script, args)
|
||||
|
||||
def run_js_loaded(self, script, as_expr=False, *args):
|
||||
def run_js_loaded(self, script, *args, as_expr=False):
|
||||
"""运行javascript代码,执行前等待页面加载完毕
|
||||
:param script: js文本
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:param args: 参数,按顺序在js文本中对应argument[0]、argument[1]...
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:return: 运行的结果
|
||||
"""
|
||||
self.wait.load_complete()
|
||||
return run_js(self, script, as_expr, self.timeouts.script, args)
|
||||
|
||||
def run_async_js(self, script, as_expr=False, *args):
|
||||
def run_async_js(self, script, *args, as_expr=False):
|
||||
"""以异步方式执行js代码
|
||||
:param script: js文本
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:param args: 参数,按顺序在js文本中对应argument[0]、argument[1]...
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:return: None
|
||||
"""
|
||||
from threading import Thread
|
||||
|
@ -121,11 +121,11 @@ class ChromiumBase(BasePage):
|
||||
@property
|
||||
def set(self) -> ChromiumBaseSetter: ...
|
||||
|
||||
def run_js(self, script: str, as_expr: bool = False, *args: Any) -> Any: ...
|
||||
def run_js(self, script: str, *args: Any, as_expr: bool = False) -> Any: ...
|
||||
|
||||
def run_js_loaded(self, script: str, as_expr: bool = False, *args: Any) -> Any: ...
|
||||
def run_js_loaded(self, script: str, *args: Any, as_expr: bool = False) -> Any: ...
|
||||
|
||||
def run_async_js(self, script: str, as_expr: bool = False, *args: Any) -> None: ...
|
||||
def run_async_js(self, script: str, *args: Any, as_expr: bool = False) -> None: ...
|
||||
|
||||
def get(self,
|
||||
url: str,
|
||||
|
@ -11,7 +11,7 @@ from warnings import warn
|
||||
|
||||
from .base import DrissionElement, BaseElement
|
||||
from .common.constants import FRAME_ELEMENT, NoneElement
|
||||
from .common.errors import ContextLossError, ElementLossError, CallMethodError, JavaScriptError
|
||||
from .common.errors import ContextLossError, ElementLossError, JavaScriptError
|
||||
from .common.locator import get_loc
|
||||
from .common.web import make_absolute_link, get_ele_txt, format_html, is_js_func, location_in_viewport, offset_scroll
|
||||
from .keys import _keys_to_typing, _keyDescriptionForString, _keyDefinitions
|
||||
@ -325,20 +325,20 @@ class ChromiumElement(DrissionElement):
|
||||
|
||||
return format_html(i['value']['value'])
|
||||
|
||||
def run_js(self, script, as_expr=False, *args):
|
||||
def run_js(self, script, *args, as_expr=False):
|
||||
"""运行javascript代码
|
||||
:param script: js文本
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:param args: 参数,按顺序在js文本中对应argument[0]、argument[1]...
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:return: 运行的结果
|
||||
"""
|
||||
return run_js(self, script, as_expr, self.page.timeouts.script, args)
|
||||
|
||||
def run_async_js(self, script, as_expr=False, *args):
|
||||
def run_async_js(self, script, *args, as_expr=False):
|
||||
"""以异步方式执行js代码
|
||||
:param script: js文本
|
||||
:param args: 参数,按顺序在js文本中对应argument[0]、argument[1]...
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:param args: 参数,按顺序在js文本中对应argument[0]、argument[2]...
|
||||
:return: None
|
||||
"""
|
||||
from threading import Thread
|
||||
@ -864,20 +864,20 @@ class ChromiumShadowRootElement(BaseElement):
|
||||
self._states = ShadowRootElementStates(self)
|
||||
return self._states
|
||||
|
||||
def run_js(self, script, as_expr=False, *args):
|
||||
def run_js(self, script, *args, as_expr=False):
|
||||
"""运行javascript代码
|
||||
:param script: js文本
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:param args: 参数,按顺序在js文本中对应argument[0]、argument[1]...
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:return: 运行的结果
|
||||
"""
|
||||
return run_js(self, script, as_expr, self.page.timeouts.script, args)
|
||||
|
||||
def run_async_js(self, script, as_expr=False, *args):
|
||||
def run_async_js(self, script, *args, as_expr=False):
|
||||
"""以异步方式执行js代码
|
||||
:param script: js文本
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:param args: 参数,按顺序在js文本中对应argument[0]、argument[1]...
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:return: None
|
||||
"""
|
||||
from threading import Thread
|
||||
|
@ -144,9 +144,9 @@ class ChromiumElement(DrissionElement):
|
||||
|
||||
def prop(self, prop: str) -> Union[str, int, None]: ...
|
||||
|
||||
def run_js(self, script: str, as_expr: bool = False, *args: Any) -> Any: ...
|
||||
def run_js(self, script: str, *args: Any, as_expr: bool = False) -> Any: ...
|
||||
|
||||
def run_async_js(self, script: str, as_expr: bool = False, *args: Any) -> None: ...
|
||||
def run_async_js(self, script: str, *args: Any, as_expr: bool = False) -> None: ...
|
||||
|
||||
def ele(self,
|
||||
loc_or_str: Union[Tuple[str, str], str],
|
||||
@ -253,9 +253,9 @@ class ChromiumShadowRootElement(BaseElement):
|
||||
@property
|
||||
def inner_html(self) -> str: ...
|
||||
|
||||
def run_js(self, script: str, as_expr: bool = False, *args: Any) -> Any: ...
|
||||
def run_js(self, script: str, *args: Any, as_expr: bool = False) -> Any: ...
|
||||
|
||||
def run_async_js(self, script: str, as_expr: bool = False, *args: Any) -> None: ...
|
||||
def run_async_js(self, script: str, *args: Any, as_expr: bool = False) -> None: ...
|
||||
|
||||
def parent(self, level_or_loc: Union[str, int] = 1) -> ChromiumElement: ...
|
||||
|
||||
|
@ -283,11 +283,11 @@ class ChromiumFrame(ChromiumBase):
|
||||
self._check_ok()
|
||||
self.frame_ele.remove_attr(attr)
|
||||
|
||||
def run_js(self, script, as_expr=False, *args):
|
||||
def run_js(self, script, *args, as_expr=False):
|
||||
"""运行javascript代码
|
||||
:param script: js文本
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:param args: 参数,按顺序在js文本中对应argument[0]、argument[1]...
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:return: 运行的结果
|
||||
"""
|
||||
self._check_ok()
|
||||
|
@ -107,7 +107,7 @@ class ChromiumFrame(ChromiumBase):
|
||||
|
||||
def remove_attr(self, attr: str) -> None: ...
|
||||
|
||||
def run_js(self, script: str, as_expr: bool = False, *args: Any) -> Any: ...
|
||||
def run_js(self, script: str, *args: Any, as_expr: bool = False) -> Any: ...
|
||||
|
||||
def parent(self, level_or_loc: Union[tuple, str, int] = 1) -> Union[ChromiumElement, None]: ...
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user