title: Selenium How to wait multiple times for the same WebElement with different text
body: <p>I'm attempting to wait for the WebElement to change from blank,to message 1, then message 2. The problem is I find the first message everytime, but i can't ever seem to wait for the second(it timesout looking for the text) </p>
  
  <p>I've tried having the wait objects separate that didnt work. Ive tried a few of the expected condition methods(textToBePresent*), which after some reading (i found about the refreshed EC) to no avail.</p>
  
  <pre><code>@FindBy(xpath="//p[@class='statusText']")
  WebElement statusMsg
  public WebElement statusMsg(){
  
      String msg1="Logging in, please wait."
      String msg2="Login successful, please wait."
      String msg3="Login attempt exception, error code: "
      if(statusMsg.getText().contains(msg3)){
          log.error(statusMsg.getText())
          log.error("Something happened in the frontend")
          Assert.fail(statusMsg.getText())
      }else{
          log.info(statusMsg.getText())
      }
      WebDriverWait wait = new WebDriverWait(driver,45)
      wait.until(ExpectedConditions.textToBe(By.xpath("//p[@class='statusText']"), msg1))
      if(statusMsg.getText().contains(msg3)){
          log.error(statusMsg.getText())
          log.error("Something happened in the backend")
          Assert.fail(statusMsg.getText())
      }else{
          log.info(statusMsg.getText())
      }
      wait.until(ExpectedConditions.refreshed(ExpectedConditions.textToBe(By.xpath("//p[@class='statusText']"), msg2)))
      log.info("Found: "+msg2)
      return statusMsg
  }
  </code></pre>
  
  <p>The result is testNG fails my test saying:</p>
  
  <blockquote>
    <p>org.openqa.selenium.TimeoutException: Expected condition failed:
    waiting for condition (element found by By.xpath:
    //p[@class='statusText'] to have text "Login successful, please
    wait.". Current text: "Logging in, please wait.")</p>
  </blockquote>
  
  <p><p>Yet I can see the <code>msg2</code> while the test is running. Does this have to do because I've already initialised the page objects via <code>PageFactory.initElements(driver, this)</code>?</p>