修复run_script()漏了args的问题

This commit is contained in:
g1879 2020-08-18 14:18:04 +08:00
parent 6162939809
commit 701b889447
2 changed files with 8 additions and 6 deletions

View File

@ -290,12 +290,13 @@ class DriverElement(DrissionElement):
print(e)
return False
def run_script(self, script: str) -> Any:
"""执行js \n
def run_script(self, script: str, *args) -> Any:
"""执行js代码,传入自己为第一个参数 \n
:param script: js文本
:param args: 传入的参数
:return: js执行结果
"""
return self.inner_ele.parent.execute_script(script, self.inner_ele)
return self.inner_ele.parent.execute_script(script, self.inner_ele, *args)
def submit(self) -> None:
"""提交表单"""

View File

@ -216,12 +216,13 @@ class DriverPage(object):
"""
return None
def run_script(self, script: str) -> Any:
"""执行js \n
def run_script(self, script: str, *args) -> Any:
"""执行js代码 \n
:param script: js文本
:param args: 传入的参数
:return: js执行结果
"""
return self.driver.execute_script(script)
return self.driver.execute_script(script, *args)
@property
def tabs_count(self) -> int: