修复get()超时没try问题

This commit is contained in:
g1879 2023-11-01 23:32:14 +08:00
parent f278a32ede
commit e8f3cf8df3
2 changed files with 10 additions and 10 deletions

View File

@ -862,13 +862,13 @@ class ChromiumBase(BasePage):
for t in range(times + 1):
err = None
end_time = perf_counter() + timeout
result = self.run_cdp('Page.navigate', url=to_url, _timeout=timeout)
if result.get('error') == 'timeout':
try:
result = self.run_cdp('Page.navigate', url=to_url, _timeout=timeout)
if 'errorText' in result:
err = ConnectionError(result['errorText'])
except TimeoutError:
err = TimeoutError('页面连接超时。')
elif 'errorText' in result:
err = ConnectionError(result['errorText'])
if err:
sleep(interval)
if self._debug or show_errmsg:

View File

@ -611,13 +611,13 @@ class ChromiumFrame(ChromiumBase):
for t in range(times + 1):
err = None
end_time = perf_counter() + timeout
result = self.driver.call_method('Page.navigate', url=to_url, frameId=self.frame_id, _timeout=timeout)
if result.get('error') == 'timeout':
try:
result = self.run_cdp('Page.navigate', url=to_url, _timeout=timeout)
if 'errorText' in result:
err = ConnectionError(result['errorText'])
except TimeoutError:
err = TimeoutError('页面连接超时。')
elif 'errorText' in result:
err = ConnectionError(result['errorText'])
if err:
sleep(interval)
if self._debug or show_errmsg: