Beispiel #1
0
  @Test
  public void testGreaterThanMaximum() {
    page.fillCorrectValues();
    page.fillLongerJob();
    page.validate();
    page.getMessageForJob().advanced().waitUntilMessageIsVisible().perform();
    assertTrue(
        "The message for the Job input should be present.",
        page.getMessageForJob().advanced().isVisible());
    assertMessageDetail("Job", page.getMessageForJob(), MessagePage.JOB_ERROR_GREATER_THAN_MAXIMUM);

    for (Message message :
        new Message[] {
          page.getMessageForAddress(), page.getMessageForName(), page.getMessageForZip()
        }) {
      assertFalse("Unexpected message is present.", message.advanced().isVisible());
    }

    page.fillLongerZip();
    page.validate();
    page.getMessageForZip().advanced().waitUntilMessageIsVisible().perform();
    assertTrue(
        "A message for the Job input should be present.",
        page.getMessageForJob().advanced().isVisible());
    assertMessageDetail("Job", page.getMessageForJob(), MessagePage.JOB_ERROR_GREATER_THAN_MAXIMUM);

    assertTrue(
        "A message for the Zip input should be present.",
        page.getMessageForZip().advanced().isVisible());
    assertMessageDetail("Zip", page.getMessageForZip(), MessagePage.ZIP_ERROR_GREATER_THAN_MAXIMUM);

    for (Message message : new Message[] {page.getMessageForAddress(), page.getMessageForName()}) {
      assertFalse("Unexpected message is present.", message.advanced().isVisible());
    }
  }
Beispiel #2
0
 protected void assertMessageDetail(String fieldName, Message message, String expected) {
   assertTrue(
       "The message detail for '"
           + fieldName
           + "' should contain '"
           + expected
           + "', but it is '"
           + message.getDetail()
           + "'",
       message.getDetail().contains(expected));
 }