mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
wait.load_complete()改为wait.doc_loaded()
This commit is contained in:
parent
5a80707e38
commit
c810b15c4a
@ -1177,7 +1177,7 @@ def find_by_xpath(ele, xpath, index, timeout, relative=True):
|
||||
type_txt = '9' if index == 1 else '7'
|
||||
node_txt = 'this.contentDocument' if ele.tag in __FRAME_ELEMENT__ and not relative else 'this'
|
||||
js = make_js_for_find_ele_by_xpath(xpath, type_txt, node_txt)
|
||||
ele.page.wait.load_complete()
|
||||
ele.page.wait.doc_loaded()
|
||||
|
||||
def do_find():
|
||||
res = ele.page.run_cdp('Runtime.callFunctionOn', functionDeclaration=js, objectId=ele._obj_id,
|
||||
@ -1245,7 +1245,7 @@ def find_by_css(ele, selector, index, timeout):
|
||||
node_txt = 'this.contentDocument' if ele.tag in ('iframe', 'frame', 'shadow-root') else 'this'
|
||||
js = f'function(){{return {node_txt}.querySelector{find_all}("{selector}");}}'
|
||||
|
||||
ele.page.wait.load_complete()
|
||||
ele.page.wait.doc_loaded()
|
||||
|
||||
def do_find():
|
||||
res = ele.page.run_cdp('Runtime.callFunctionOn', functionDeclaration=js, objectId=ele._obj_id,
|
||||
|
@ -290,7 +290,7 @@ class ChromiumBase(BasePage):
|
||||
"""返回用于执行动作链的对象"""
|
||||
if self._actions is None:
|
||||
self._actions = Actions(self)
|
||||
self.wait.load_complete()
|
||||
self.wait.doc_loaded()
|
||||
return self._actions
|
||||
|
||||
@property
|
||||
@ -310,7 +310,7 @@ class ChromiumBase(BasePage):
|
||||
@property
|
||||
def scroll(self):
|
||||
"""返回用于滚动滚动条的对象"""
|
||||
self.wait.load_complete()
|
||||
self.wait.doc_loaded()
|
||||
if self._scroll is None:
|
||||
self._scroll = PageScroller(self)
|
||||
return self._scroll
|
||||
@ -318,7 +318,7 @@ class ChromiumBase(BasePage):
|
||||
@property
|
||||
def rect(self):
|
||||
"""返回获取窗口坐标和大小的对象"""
|
||||
# self.wait.load_complete()
|
||||
# self.wait.doc_loaded()
|
||||
if self._rect is None:
|
||||
self._rect = TabRect(self)
|
||||
return self._rect
|
||||
@ -359,7 +359,7 @@ class ChromiumBase(BasePage):
|
||||
@property
|
||||
def html(self):
|
||||
"""返回当前页面html文本"""
|
||||
self.wait.load_complete()
|
||||
self.wait.doc_loaded()
|
||||
return self.run_cdp('DOM.getOuterHTML', objectId=self._root_id)['outerHTML']
|
||||
|
||||
@property
|
||||
@ -426,7 +426,7 @@ class ChromiumBase(BasePage):
|
||||
:param cmd_args: 参数
|
||||
:return: 执行的结果
|
||||
"""
|
||||
self.wait.load_complete()
|
||||
self.wait.doc_loaded()
|
||||
return self.run_cdp(cmd, **cmd_args)
|
||||
|
||||
def run_js(self, script, *args, as_expr=False, timeout=None):
|
||||
@ -447,7 +447,7 @@ class ChromiumBase(BasePage):
|
||||
:param timeout: js超时时间(秒),为None则使用页面timeouts.script属性值
|
||||
:return: 运行的结果
|
||||
"""
|
||||
self.wait.load_complete()
|
||||
self.wait.doc_loaded()
|
||||
return run_js(self, script, as_expr, self.timeouts.script if timeout is None else timeout, args)
|
||||
|
||||
def run_async_js(self, script, *args, as_expr=False):
|
||||
@ -546,7 +546,7 @@ class ChromiumBase(BasePage):
|
||||
else:
|
||||
raise ValueError('loc_or_str参数只能是tuple、str、ChromiumElement类型。')
|
||||
|
||||
self.wait.load_complete()
|
||||
self.wait.doc_loaded()
|
||||
timeout = timeout if timeout is not None else self.timeout
|
||||
end_time = perf_counter() + timeout
|
||||
|
||||
|
@ -212,7 +212,7 @@ class ChromiumFrame(ChromiumBase):
|
||||
@property
|
||||
def scroll(self):
|
||||
"""返回用于滚动的对象"""
|
||||
self.wait.load_complete()
|
||||
self.wait.doc_loaded()
|
||||
if self._scroll is None:
|
||||
self._scroll = FrameScroller(self)
|
||||
return self._scroll
|
||||
@ -573,7 +573,7 @@ class ChromiumFrame(ChromiumBase):
|
||||
"""
|
||||
if isinstance(loc_or_ele, ChromiumElement):
|
||||
return loc_or_ele
|
||||
self.wait.load_complete()
|
||||
self.wait.doc_loaded()
|
||||
return self.doc_ele._ele(loc_or_ele, index=index, timeout=timeout,
|
||||
raise_err=raise_err) if index is not None else self.doc_ele.eles(loc_or_ele, timeout)
|
||||
|
||||
|
@ -96,7 +96,7 @@ class BaseWaiter(object):
|
||||
"""
|
||||
return self._loading(timeout=timeout, gap=.002, raise_err=raise_err)
|
||||
|
||||
def load_complete(self, timeout=None, raise_err=None):
|
||||
def doc_loaded(self, timeout=None, raise_err=None):
|
||||
"""等待页面加载完成
|
||||
:param timeout: 超时时间,为None时使用页面timeout属性
|
||||
:param raise_err: 等待失败时是否报错,为None时根据Settings设置
|
||||
@ -215,6 +215,14 @@ class BaseWaiter(object):
|
||||
:return: count为1时返回数据包对象,大于1时返回列表,超时且fix_count为True时返回False"""
|
||||
return self._driver.listen.wait(count, timeout, fix_count)
|
||||
|
||||
def load_complete(self, timeout=None, raise_err=None):
|
||||
"""等待页面加载完成
|
||||
:param timeout: 超时时间,为None时使用页面timeout属性
|
||||
:param raise_err: 等待失败时是否报错,为None时根据Settings设置
|
||||
:return: 是否等待成功
|
||||
"""
|
||||
return self._loading(timeout=timeout, start=False, raise_err=raise_err)
|
||||
|
||||
|
||||
class TabWaiter(BaseWaiter):
|
||||
|
||||
|
@ -42,8 +42,6 @@ class BaseWaiter(object):
|
||||
|
||||
def load_start(self, timeout: float = None, raise_err: bool = None) -> bool: ...
|
||||
|
||||
def load_complete(self, timeout: float = None, raise_err: bool = None) -> bool: ...
|
||||
|
||||
def upload_paths_inputted(self) -> bool: ...
|
||||
|
||||
def download_begin(self, timeout: float = None, cancel_it: bool = False) -> Union[DownloadMission, bool]: ...
|
||||
|
Loading…
x
Reference in New Issue
Block a user