I want my code to be able to handle circumstances when the internet goes down for a period. Currently I'm doing it using a try/except clause with a TimeoutException but that isn't working as Chrome doesn't Timeout when there is no internet, it just returns this page:
No Internet
Try:
Checking the network cables, modem and router
Reconnecting to Wi-Fi
ERR_INTERNET_DISCONNECTED
Since there's no timeout, my code just continues searching for elements and the loss of internet is not caught.
Is there anyway of raising an exception when there is no internet in chrome?
Code:
driver = webdriver.Chrome(executable_path=mypath)
driver.implicitly_wait(10)
driver.set_page_load_timeout(10)
try:
driver.get(url)
elem = driver.find_element_by_xpath(xpath).get_attribute("content")
except TimeoutException:
print('TimeoutException')