I am using Chrome with selenium and the test run well, until suddenly internet/proxy connection is down, then browser.get(url) get me this:
If I reload the page 99% it will load fine, what is the proper way to handle this ?
MY CODE:
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')
I am not getting into TIMEOUT EXCEPTION but to the break part.