title: How to test Login error validation python selenium
body: <p>I need to test Login page validation.  If the user doesn't enter username, then the formErrorContent need to show beside the username.</p>
  
  <p>This is what I did</p>
  
  <pre><code>    def test_UserNameValidate(self):
      self.driver.getElement("id", "user").click()
      self.driver.getElement("id", "password").click()
      user = self.driver.getElement("id", "user")
      try:
         error_user = user.find_element_by_xpath('//*[@id="login-usr"]/div/div[@class="formErrorContent"]')
      except NoSuchElementException:
          error_user = None
  </code></pre>
  
  <p>This test is passing. I got the try and except method from web and changed for my condition.  I'm not sure I'm doing right validation. Also, I didn't understand whats going on Try and except.  Can someone help to solve this puzzle?</p>
  
  <p>Thanks</p>