title: Selenium Loss of Internet Exception Handling using Python and Chromedriver
body: <p>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:</p>
  
  <blockquote>
    <p>No Internet</p>
    
    <p>Try:</p>
    
    <ul>
    <li><p>Checking the network cables, modem and router</p></li>
    <li><p>Reconnecting to Wi-Fi</p></li>
    </ul>
    
    <p>ERR_INTERNET_DISCONNECTED</p>
  </blockquote>
  
  <p>Since there's no timeout, my code just continues searching for elements and the loss of internet is not caught.</p>
  
  <p>Is there anyway of raising an exception when there is no internet in chrome?</p>
  
  <hr>
  
  <p>Code:</p>
  
  <pre><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')
  </code></pre>