title: How to use the try/except with Selenium Webdriver when having Exceptions on Python
body: <p>I'm trying the use a try/except statement to findout if an element exists in the WebDrive or not, if so then run a specific code line,</p>
  
  <pre><code>try:
      WebDriver.find_element_by_css_selector('div[class="..."')
  except NoSuchElement:
      ActionToRunInCaseNoSuchElementTrue
  else:
      ActionToRunInCaseNoSuchElementFalse
  </code></pre>
  
  <p>but running this code gives an error:  </p>
  
  <ul>
  <li>NameError: name 'NoSuchElement' is not defined  </li>
  </ul>
  
  <p>how should the Exception be defined?
  Is there any shorter/easier way to check if an element does exist in a web page and run a command if so and another if not?</p>