mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
bugfix: run_js的cdp命令为毫秒,但是框架默认用秒为计时单位,修复统一了单位,修复代码内注释
This commit is contained in:
parent
c886916dc0
commit
7512eb0157
@ -80,7 +80,7 @@ class ChromiumElement(DrissionElement):
|
||||
def __call__(self, loc_or_str, timeout=None):
|
||||
"""在内部查找元素
|
||||
:param loc_or_str: 元素的定位信息,可以是loc元组,或查询字符串
|
||||
:param timeout: 超时时间
|
||||
:param timeout: 超时时间(秒)
|
||||
:return: ChromiumElement对象或属性、文本
|
||||
"""
|
||||
return self.ele(loc_or_str, timeout)
|
||||
@ -1336,10 +1336,13 @@ def run_js(page_or_ele, script, as_expr=False, timeout=None, args=None):
|
||||
:param page_or_ele: 页面对象或元素对象
|
||||
:param script: js文本
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:param timeout: 超时时间
|
||||
:param timeout: 超时时间(秒)
|
||||
:param args: 参数,按顺序在js文本中对应arguments[0]、arguments[1]...
|
||||
:return: js执行结果
|
||||
"""
|
||||
# 将timeout转换为毫秒
|
||||
if timeout is not None:
|
||||
timeout *= 1000
|
||||
if isinstance(page_or_ele, (ChromiumElement, ShadowRoot)):
|
||||
is_page = False
|
||||
page = page_or_ele.page
|
||||
|
@ -38,7 +38,7 @@ class ChromiumBase(BasePage):
|
||||
"""
|
||||
:param address: 浏览器 ip:port
|
||||
:param tab_id: 要控制的标签页id,不指定默认为激活的
|
||||
:param timeout: 超时时间
|
||||
:param timeout: 超时时间(秒)
|
||||
"""
|
||||
super().__init__()
|
||||
self._is_loading = None
|
||||
@ -147,7 +147,7 @@ class ChromiumBase(BasePage):
|
||||
|
||||
def _get_document(self, timeout=10):
|
||||
"""获取页面文档
|
||||
:param timeout: 超时时间
|
||||
:param timeout: 超时时间(秒)
|
||||
:return: 是否获取成功
|
||||
"""
|
||||
if self._debug:
|
||||
@ -282,7 +282,7 @@ class ChromiumBase(BasePage):
|
||||
"""在内部查找元素
|
||||
例:ele = page('@id=ele_id')
|
||||
:param loc_or_str: 元素的定位信息,可以是loc元组,或查询字符串
|
||||
:param timeout: 超时时间
|
||||
:param timeout: 超时时间(秒)
|
||||
:return: ChromiumElement对象
|
||||
"""
|
||||
return self.ele(loc_or_str, timeout)
|
||||
@ -468,7 +468,7 @@ class ChromiumBase(BasePage):
|
||||
:param script: js文本
|
||||
:param args: 参数,按顺序在js文本中对应arguments[0]、arguments[1]...
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:param timeout: js超时时间,为None则使用页面timeouts.script设置
|
||||
:param timeout: js超时时间,为None则使用页面timeouts.script设置(秒)
|
||||
:return: 运行的结果
|
||||
"""
|
||||
return run_js(self, script, as_expr, self.timeouts.script if timeout is None else timeout, args)
|
||||
@ -478,7 +478,7 @@ class ChromiumBase(BasePage):
|
||||
:param script: js文本
|
||||
:param args: 参数,按顺序在js文本中对应arguments[0]、arguments[1]...
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:param timeout: js超时时间,为None则使用页面timeouts.script设置
|
||||
:param timeout: js超时时间,为None则使用页面timeouts.script设置(秒)
|
||||
:return: 运行的结果
|
||||
"""
|
||||
self.wait.load_complete()
|
||||
@ -489,7 +489,7 @@ class ChromiumBase(BasePage):
|
||||
:param script: js文本
|
||||
:param args: 参数,按顺序在js文本中对应arguments[0]、arguments[1]...
|
||||
:param as_expr: 是否作为表达式运行,为True时args无效
|
||||
:param timeout: js超时时间,为None则使用页面timeouts.script设置
|
||||
:param timeout: js超时时间,为None则使用页面timeouts.script设置(秒)
|
||||
:return: None
|
||||
"""
|
||||
from threading import Thread
|
||||
@ -502,7 +502,7 @@ class ChromiumBase(BasePage):
|
||||
:param show_errmsg: 是否显示和抛出异常
|
||||
:param retry: 重试次数
|
||||
:param interval: 重试间隔(秒)
|
||||
:param timeout: 连接超时时间
|
||||
:param timeout: 连接超时时间(秒)
|
||||
:return: 目标url是否可用
|
||||
"""
|
||||
retry, interval = self._process_connection(url, retry, interval)
|
||||
@ -531,7 +531,7 @@ class ChromiumBase(BasePage):
|
||||
def ele(self, loc_or_ele, timeout=None):
|
||||
"""获取第一个符合条件的元素对象
|
||||
:param loc_or_ele: 定位符或元素对象
|
||||
:param timeout: 查找超时时间
|
||||
:param timeout: 查找超时时间(秒)
|
||||
:return: ChromiumElement对象
|
||||
"""
|
||||
return self._ele(loc_or_ele, timeout=timeout, method='ele()')
|
||||
@ -539,7 +539,7 @@ class ChromiumBase(BasePage):
|
||||
def eles(self, loc_or_str, timeout=None):
|
||||
"""获取所有符合条件的元素对象
|
||||
:param loc_or_str: 定位符或元素对象
|
||||
:param timeout: 查找超时时间
|
||||
:param timeout: 查找超时时间(秒)
|
||||
:return: ChromiumElement对象组成的列表
|
||||
"""
|
||||
return self._ele(loc_or_str, timeout=timeout, single=False)
|
||||
@ -568,7 +568,7 @@ class ChromiumBase(BasePage):
|
||||
def _find_elements(self, loc_or_ele, timeout=None, single=True, relative=False, raise_err=None):
|
||||
"""执行元素查找
|
||||
:param loc_or_ele: 定位符或元素对象
|
||||
:param timeout: 查找超时时间
|
||||
:param timeout: 查找超时时间(秒)
|
||||
:param single: 是否只返回第一个
|
||||
:param relative: WebPage用的表示是否相对定位的参数
|
||||
:param raise_err: 找不到元素是是否抛出异常,为None时根据全局设置
|
||||
@ -712,7 +712,7 @@ class ChromiumBase(BasePage):
|
||||
def get_frame(self, loc_ind_ele, timeout=None):
|
||||
"""获取页面中一个frame对象,可传入定位符、iframe序号、ChromiumFrame对象,序号从1开始
|
||||
:param loc_ind_ele: 定位符、iframe序号、ChromiumFrame对象
|
||||
:param timeout: 查找元素超时时间
|
||||
:param timeout: 查找元素超时时间(秒)
|
||||
:return: ChromiumFrame对象
|
||||
"""
|
||||
if isinstance(loc_ind_ele, str):
|
||||
@ -752,7 +752,7 @@ class ChromiumBase(BasePage):
|
||||
def get_frames(self, loc=None, timeout=None):
|
||||
"""获取所有符合条件的frame对象
|
||||
:param loc: 定位符,为None时返回所有
|
||||
:param timeout: 查找超时时间
|
||||
:param timeout: 查找超时时间(秒)
|
||||
:return: ChromiumFrame对象组成的列表
|
||||
"""
|
||||
loc = loc or 'xpath://*[name()="iframe" or name()="frame"]'
|
||||
@ -849,7 +849,7 @@ class ChromiumBase(BasePage):
|
||||
"""处理提示框,可以自动等待提示框出现
|
||||
:param accept: True表示确认,False表示取消,其它值不会按按钮但依然返回文本值
|
||||
:param send: 处理prompt提示框时可输入文本
|
||||
:param timeout: 等待提示框出现的超时时间,为None则使用self.timeout属性的值
|
||||
:param timeout: 等待提示框出现的超时时间,为None则使用self.timeout属性的值(秒)
|
||||
:param next_one: 是否处理下一个出现的提示框,为True时timeout参数无效
|
||||
:return: 提示框内容文本,未等到提示框则返回False
|
||||
"""
|
||||
@ -901,7 +901,7 @@ class ChromiumBase(BasePage):
|
||||
|
||||
def _wait_loaded(self, timeout=None):
|
||||
"""等待页面加载完成,超时触发停止加载
|
||||
:param timeout: 超时时间
|
||||
:param timeout: 超时时间(秒)
|
||||
:return: 是否成功,超时返回False
|
||||
"""
|
||||
if self._load_mode == 'none':
|
||||
@ -948,7 +948,7 @@ class ChromiumBase(BasePage):
|
||||
:param times: 重试次数
|
||||
:param interval: 重试间隔(秒)
|
||||
:param show_errmsg: 是否抛出异常
|
||||
:param timeout: 连接超时时间
|
||||
:param timeout: 连接超时时间(秒)
|
||||
:return: 是否成功,返回None表示不确定
|
||||
"""
|
||||
err = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user