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.

GridApplyFilterWhenScrolledDownTest.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package com.vaadin.tests.components.grid;
  2. import static org.junit.Assert.assertEquals;
  3. import static org.junit.Assert.assertTrue;
  4. import org.junit.Test;
  5. import org.openqa.selenium.WebElement;
  6. import com.vaadin.testbench.By;
  7. import com.vaadin.testbench.TestBenchElement;
  8. import com.vaadin.testbench.elements.ButtonElement;
  9. import com.vaadin.testbench.elements.GridElement;
  10. import com.vaadin.tests.tb3.MultiBrowserTest;
  11. public class GridApplyFilterWhenScrolledDownTest extends MultiBrowserTest {
  12. @Test
  13. public void scrolledCorrectly() throws InterruptedException {
  14. openTestURL();
  15. final GridElement grid = $(GridElement.class).first();
  16. grid.scrollToRow(50);
  17. $(ButtonElement.class).first().click();
  18. final TestBenchElement gridBody = grid.getBody();
  19. // Can't use element API because it scrolls
  20. waitUntil(input -> gridBody.findElements(By.className("v-grid-row"))
  21. .size() == 1);
  22. WebElement cell = gridBody.findElements(By.className("v-grid-cell"))
  23. .get(0);
  24. assertEquals("Test", cell.getText());
  25. int gridHeight = grid.getSize().getHeight();
  26. int scrollerHeight = grid.getVerticalScroller().getSize().getHeight();
  27. assertTrue(
  28. "Scroller height is " + scrollerHeight
  29. + ", should be smaller than grid height: " + gridHeight,
  30. scrollerHeight < gridHeight);
  31. }
  32. }