我使用的是Chrome和selenium,测试运行得很好,直到突然互联网/代理连接断开浏览器.get(url)给我这个:
如果我重新加载页面99%,它将加载良好,什么是正确的方式来处理这一点?在
我的代码:def web_adress_navigator(browser, link):
"""Checks and compares current URL of web page and the URL to be navigated and if it is different, it does navigate"""
try:
current_url = browser.current_url
except WebDriverException:
try:
current_url = browser.execute_script("return window.location.href")
except WebDriverException:
current_url = None
if current_url is None or current_url != link:
retries = 5
while retries > 0:
try:
browser.get(link)
break
except TimeoutException:
logger.warning('TimeoutException when tring to reach page')
retries -= 1
while not is_connected():
sleep(60)
logger.warning('there is no valid connection')
我不是进入超时异常,而是中断部分。在