title: verify element existence selenium
body: <p>I know that this question has been asked in some iteration before. But I can't figure out how to do this even after looking at the API. </p>
  
  <p>I want to scrape data over the web and I have the following code:</p>
  
  <pre><code>browser = webdriver.Firefox()
  browser.get(url)
  browser.find_element_by_xpath('//path')
  </code></pre>
  
  <p>Now before the find_element part executes. I want to know if the element in fact exists. I've tried the following:</p>
  
  <pre><code>try:
      browser.find_element_by_xpath('//path')
  except NoSuchElementException:
      print ('failure')
  </code></pre>
  
  <p>AND</p>
  
  <pre><code>if (browser.find_element_by_xpath('//path')[0].size() == 0):
      print ('failure')
  </code></pre>
  
  <p>But neither of them work, even though the API says size() is a callable function of <code>WebElement</code> and the exception is throw by the <code>find</code> family of methods. I don't understand why neither of those work. But if anyone could give me an explanation and a working example I would greatly appreciate it. </p>