You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MultipleValidationErrorsTest.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package com.vaadin.tests.fieldgroup;
  2. import static org.hamcrest.CoreMatchers.containsString;
  3. import static org.hamcrest.MatcherAssert.assertThat;
  4. import org.junit.Test;
  5. import com.vaadin.testbench.elements.ButtonElement;
  6. import com.vaadin.testbench.elements.LabelElement;
  7. import com.vaadin.testbench.elements.TextFieldElement;
  8. import com.vaadin.tests.tb3.MultiBrowserTest;
  9. public class MultipleValidationErrorsTest extends MultiBrowserTest {
  10. private void commitTextFields() {
  11. $(ButtonElement.class).caption("Submit").first().click();
  12. }
  13. private void clearTextField(String caption) {
  14. TextFieldElement textField = $(TextFieldElement.class).caption(caption)
  15. .first();
  16. textField.clear();
  17. }
  18. @Test
  19. public void validationErrorsIncludeBothErrors() {
  20. openTestURL();
  21. clearTextField("First Name");
  22. clearTextField("Last Name");
  23. commitTextFields();
  24. String validationErrors = $(LabelElement.class).id("validationErrors")
  25. .getText();
  26. assertThat(validationErrors, containsString(
  27. MultipleValidationErrors.FIRST_NAME_NOT_EMPTY_VALIDATION_MESSAGE));
  28. assertThat(validationErrors, containsString(
  29. MultipleValidationErrors.LAST_NAME_NOT_EMPTY_VALIDATION_MESSAGE));
  30. }
  31. }