title: Changing Xpath on the same URL makes Assert in Login Test to fail
body: <p>I have created a negative test case for a webpage login URL.</p>
  
  <p>In LoginPage(java) I have defined a Webelement(alertMessage), before hit login Firepath is :  </p>
  
  <pre><code>&lt;div id="submit-box"&gt;
  &lt;div id="loginAlert" class="loginAlert"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>After Hit Firepath-ul is modifing because the user is wrong:  </p>
  
  <pre><code>&lt;div id="submit-box"&gt;
  &lt;div id="loginAlert" class="loginAlert"&gt;User doesn't exist.&lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The URL remains the same after hit login. </p>
  
  <p>Running the test in  Maven, I have  Assert error: </p>
  
  <pre><code>java.lang.AssertionError: 
  Expected: a string containing "Wrong password."
       but: was ""
  Expected :a string containing "Wrong password."
  
  Actual   :""
   &lt;Click to see difference&gt;
  </code></pre>
  
  <p>My java package for LoginPage: </p>
  
  <pre><code>package CsphEbox.Pages;
  
  import Resources.PageBase;
  import com.gargoylesoftware.htmlunit.javascript.host.Console;
  import com.sun.org.apache.xerces.internal.impl.xs.identity.Field;
  import org.junit.Assert;
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.support.FindBy;
  
  import static javax.swing.text.html.CSS.getAttribute;
  import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOf;
  
  
  public class LoginPage extends PageBase
  
  {
      @FindBy (id = "UserName")
      private WebElement loginUserNameInput;
      @FindBy (id = "UserPassword")
      private WebElement loginUserPasswordInput;
      @FindBy (id = "Submit")
      private WebElement loginButton;
      @FindBy(xpath = ".//*[@id='loginAlert']")
      private WebElement alertMessage;
  
  
      // private WebElement alertMessage;
      //String source = driver.findElement(By.xpath(".//form[@id='login']//div[@class='loginAlert' and @id='loginAlert']")).getAttribute("innerHTML");
  
      public LoginPage(WebDriver driver)
  
      { super(driver);
        waitForURLToContains("/login/login");
      }
  
      public String getAlertMessage()
  
      {
           waitForElementToBeVisible(alertMessage);
           return alertMessage.getAttribute("innerHTML");
  
      }
  
      public LoginPage loginWrongAs(String username, String password)
  
      {
          waitForElementToBeVisible(loginUserNameInput);
          loginUserNameInput.sendKeys(username);
          loginUserPasswordInput.sendKeys(password);
          loginButton.click();
          return new LoginPage(driver);
      }
  </code></pre>
  
  <p>My java package for LoginTest:</p>
  
  <pre><code>package CsphEbox.Test;
  
  import CsphEbox.Pages.ActionEboxPage;
  import CsphEbox.Pages.LoginPage;
  import Resources.TestBase;
  import org.junit.Assert;
  import org.junit.Before;
  import org.junit.Test;
  
  import static CsphEbox.Utils.LoginUtils.*;
  import static java.lang.Thread.sleep;
  import static org.hamcrest.Matchers.contains;
  import static org.hamcrest.Matchers.containsString;
  import static org.hamcrest.Matchers.is;
  import static org.junit.Assert.assertThat;
  import static org.junit.Assert.assertTrue;
  
  public class LoginTest extends TestBase
  
  {  private LoginPage loginPage;
  
     @Before
  
      public void setUp()
  
      {
          driver.get(LOGIN_PAGE_URL);
          loginPage = new LoginPage(driver);
  
      }
  
      @Test
  
      public void loginWithWrongPassword() throws Exception
  
      {
  
          LoginPage eboxLog = loginPage.loginWrongAs(USERNAME,WRONGPASSWORD);
          assertThat(eboxLog.getAlertMessage(),containsString("Wrong password."));
          sleep(2000);
      }
  </code></pre>
  
  <p>I am using Java with Selenium Webdriver.</p>
  
  <p>Does anyone knows with the xpath for the WebElement <strong>alertMessage</strong> is not updating with the LoginAlert message: "Wrong password."  ??</p>
  
  <p>Thank you!</p>