title: Selenium webdriver: verify multiple text in a page
body: <p>I have a page which will give any one of the three messages (error, warning and success) on form submit.</p>
  
  <p>The problem is only one message will be visible at a time and for the rest i am getting 'NoSuchElementException'.</p>
  
  <p>My current code is:</p>
  
  <pre><code>String expectedWarningMessage = new String("Product details already present");
  String expectedErrorMessage = new String("Case Id already exists. Please use 'Search DOA return form' to modify authorization details.");
  String expectedSuccessMessage = new String("The DOA Authorisation has been sent successfully.");
  
  String actualWarningMessage = getWebElement("apj.newdoa.warning.message").getText().trim();         
  String actualErrorMessage = getWebElement("apj.newdoa.error.message").getText().trim();    
  String actualSuccessMessage = getWebElement("apj.newdoa.success.message").getText().trim();
  
  if (actualWarningMessage.equalsIgnoreCase(expectedWarningMessage)) {
          logger.info("success");
          getWebElement("apj.newdoa.warning.yesbutton").click();
  }else if(actualErrorMessage.equalsIgnoreCase(expectedErrorMessage)) {
          logger.info("fail");
  }else if (actualSuccessMessage.equalsIgnoreCase(expectedSuccessMessage)) {
          logger.info("success");
  } else {
          logger.info("Something went Wrong");
  }
  </code></pre>
  
  <p>Please note that, all the three texts appear at different places on the DOM so the locators for the texts are different.</p>