title: Selenium Webdriver NoSuchElementException
body: <p>I am using Selenium webdriver with Python to print the contents an element but if it does not exist on the page it breaks my code and returns an exception error.</p>
  
  <pre><code>print (driver.find_element_by_id("TotalCost").text)
  </code></pre>
  
  <p></p>
  
  <pre><code>NoSuchElementException: Message: no such element: Unable to locate element 
  {"method":"id","selector":"TotalCost"}
  </code></pre>
  
  <p>What can i do to fix this error?</p>