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.

TableToggleColumnVisibilityWidthTest.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package com.vaadin.tests.components.table;
  2. import static org.junit.Assert.assertEquals;
  3. import org.junit.Test;
  4. import org.openqa.selenium.By;
  5. import com.vaadin.testbench.elements.ButtonElement;
  6. import com.vaadin.tests.tb3.MultiBrowserTest;
  7. /**
  8. * Tests that column keeps its width after it is made invisible and visible
  9. * again (#12303).
  10. *
  11. * @author Vaadin Ltd
  12. */
  13. public class TableToggleColumnVisibilityWidthTest extends MultiBrowserTest {
  14. @Test
  15. public void testColumnWidthRestoredAfterTogglingVisibility() {
  16. openTestURL();
  17. int secondColumnWidthInitial = findElements(
  18. By.className("v-table-header-cell")).get(1).getSize()
  19. .getWidth();
  20. ButtonElement toggleButton = $(ButtonElement.class).id("toggler");
  21. toggleButton.click();
  22. assertEquals("One column should be visible",
  23. findElements(By.className("v-table-header-cell")).size(), 1);
  24. toggleButton.click();
  25. assertEquals("Two columns should be visible",
  26. findElements(By.className("v-table-header-cell")).size(), 2);
  27. int secondColumnWidthRestored = findElements(
  28. By.className("v-table-header-cell")).get(1).getSize()
  29. .getWidth();
  30. assertEquals("Column width should be the same as it was before hiding",
  31. secondColumnWidthInitial, secondColumnWidthRestored);
  32. }
  33. }