title: Python-Selenium: Wait for an element to exist then return True or false
body: <p>I am trying to create a function to help determine if an element appears or disappears from a web page.</p>
  <p>This is what I have.</p>
  <pre><code>def wait_for_element_to_exist(driver, by, seconds=15, negative=False):
      wait = WebDriverWait(driver, seconds)
  
      # waiting for element to exist
      if not negative:
          try:
              wait.until(EC.presence_of_element_located(*by))
              return True
          except:
              return False
  
      #wait for element not to exist
      else:
          try:
              wait.until_not(EC.presence_of_element_located(*by))
              return True
          except:
              return False
  </code></pre>
  <p>Only thing is that it always returns FALSE no matter how how call it or if the element is present</p>
  <p><code>wait_for_element_to_exist(self.driver, (By.XPATH, 'xpath'))</code>
  returns <code>False</code></p>
  <p><code>wait_for_element_to_exist(self.driver, (By.CLASS, 'class'), negative=True)</code>
  returns <code>False</code></p>
  <p>What am I doing wrong?</p>