解决打开网页弹窗错误问题

This commit is contained in:
g1879 2023-02-14 16:48:23 +08:00
parent 464238e99d
commit ec4edf868b
2 changed files with 3 additions and 3 deletions

View File

@ -270,10 +270,10 @@ class ChromiumBase(BasePage):
@property @property
def ready_state(self): def ready_state(self):
"""返回当前页面加载状态,'loading' 'interactive' 'complete'""" """返回当前页面加载状态,'loading' 'interactive' 'complete'有弹出框时返回None"""
try: try:
return self.run_cdp('Runtime.evaluate', expression='document.readyState;')['result']['value'] return self.run_cdp('Runtime.evaluate', expression='document.readyState;')['result']['value']
except AlertExistsError: except (AlertExistsError, TypeError):
return None return None
@property @property

View File

@ -96,7 +96,7 @@ class ChromiumBase(BasePage):
def tab_id(self) -> str: ... def tab_id(self) -> str: ...
@property @property
def ready_state(self) -> str: ... def ready_state(self) -> Union[str, None]: ...
@property @property
def size(self) -> Tuple[int, int]: ... def size(self) -> Tuple[int, int]: ...