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.

TableBlurFocusTest.java 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package com.vaadin.tests.components.table;
  2. import static org.hamcrest.MatcherAssert.assertThat;
  3. import static org.junit.Assert.assertEquals;
  4. import java.util.Arrays;
  5. import org.junit.Test;
  6. import org.openqa.selenium.By;
  7. import com.vaadin.testbench.elements.TableElement;
  8. import com.vaadin.testbench.elements.ButtonElement;
  9. import com.vaadin.tests.tb3.MultiBrowserTest;
  10. public class TableBlurFocusTest extends MultiBrowserTest {
  11. @Test
  12. public void testBlurAndFocus() throws InterruptedException {
  13. openTestURL();
  14. waitForElementPresent(By.className("v-button"));
  15. assertAnyLogText("1. variable change");
  16. assertEquals("Unexpected column header,", "COLUMN2",
  17. $(TableElement.class).first().getHeaderCell(1).getCaption());
  18. assertEquals("Unexpected button caption,", "click to focus",
  19. $(ButtonElement.class).first().getCaption());
  20. $(ButtonElement.class).first().click();
  21. assertAnyLogText("2. focus", "3. focus");
  22. $(TableElement.class).first().getHeaderCell(1).click();
  23. assertAnyLogText("3. blur", "4. blur");
  24. }
  25. private void assertAnyLogText(String... texts) {
  26. assertThat(String.format(
  27. "Correct log text was not found, expected any of %s",
  28. Arrays.asList(texts)), logContainsAnyText(texts));
  29. }
  30. private boolean logContainsAnyText(String... texts) {
  31. for (String text : texts) {
  32. if (logContainsText(text)) {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. }