title: How to assert in selenium test case for login success?
body: <p>i made a <strong>success selenium test case</strong> for <strong>login page</strong>, which a user enters a correct username and password and then hit login to forwarded to home page,<strong>issue</strong> is that when i change the password in the test class, the test always success i don't know why.</p>
  
  <p>here's the test Class:</p>
  
  <pre><code>public class LoginTest extends TestCase {
  
      private WebDriver driver;
      private String baseUrl;
      private StringBuffer verificationErrors = new StringBuffer();
  
      @Before
      public void setUp() throws Exception {
          driver = new FirefoxDriver();
          baseUrl = "http://localhost:8080";
      }
  
      @Test
      public void testLoginClass() throws Exception {
          driver.get(baseUrl + "/MyAPP/login");
          driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
  
          driver.findElement(By.id("j_username")).clear();
          driver.findElement(By.id("j_username")).sendKeys("1");
          driver.findElement(By.id("j_password")).clear();
          driver.findElement(By.id("j_password")).sendKeys("wrong password");
          driver.findElement(By.id("loginBtn")).click();
  
      }
  
      @After
      public void tearDown() throws Exception {
          driver.quit();
          String verificationErrorString = verificationErrors.toString();
          if (!"".equals(verificationErrorString)) {
              fail(verificationErrorString);
          }
      }
  
      @SuppressWarnings("unused")
      private boolean isElementPresent(By by) {
          try {
              driver.findElement(by);
              return true;
          } catch (NoSuchElementException e) {
              return false;
          }
      }
  
  }
  </code></pre>
  
  <p>please advise how to handle the fail of test case, let's suppose that after sometime the database is changed and there's no such user 1 which is success right now.</p>