title: How to automate test cases for a dialog box message using selenium web driver
body: <p>I am actually new to selenium web driver and stackoverflow. I am working on automating test cases for a 'forgot password' feature which has a dialog box when unregistered email address is entered. </p>
  
  <p>I want to validate the message 'This email is not registered!' in the dialog box ,but not sure how to proceed as i am using xPath which keeps changing for the message 'This email is not registered'.</p>
  
  <p>
      
      
          
              <p>This email account is not registered!</p>
              
              
          
      </p>
  
  <pre><code>@Test
  public void checkForgotPasswordWithInvalidCredentials() throws Exception {
      driver.findElement(By.xpath(".//*[@id='forgetBtn']")).click();
      driver.findElement(By.xpath(".//*[@id='emailInput']")).sendKeys("test@test.com");
      driver.findElement(By.xpath(".//*[@id='verify_btn']")).click();
      Thread.sleep(5000);
  
  
      driver.findElement(By.xpath(".//*[@id='alert_box_14']/p")).isDisplayed();
  
  }
  </code></pre>
  
  <p>In the above code, the Xpath for the alert message(.//*[@id='alert_box_14']/p) keeps changing. </p>
  
  <p>Any help would be appreciated. Thanks!</p>