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.

GridDragSelectionWhileScrolledTest.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package com.vaadin.tests.components.grid;
  2. import static org.junit.Assert.assertFalse;
  3. import static org.junit.Assert.assertTrue;
  4. import java.io.IOException;
  5. import org.junit.Test;
  6. import org.openqa.selenium.JavascriptExecutor;
  7. import org.openqa.selenium.interactions.Actions;
  8. import com.vaadin.testbench.elements.GridElement;
  9. import com.vaadin.tests.tb3.MultiBrowserTest;
  10. public class GridDragSelectionWhileScrolledTest extends MultiBrowserTest {
  11. @Override
  12. protected boolean requireWindowFocusForIE() {
  13. return true;
  14. }
  15. @Test
  16. public void testDragSelect() throws IOException {
  17. openTestURL();
  18. // Scroll grid to view
  19. GridElement grid = $(GridElement.class).first();
  20. ((JavascriptExecutor) getDriver())
  21. .executeScript("arguments[0].scrollIntoView(true);", grid);
  22. // Drag select 2 rows
  23. new Actions(getDriver()).moveToElement(grid.getCell(3, 0), 5, 5)
  24. .clickAndHold().moveToElement(grid.getCell(2, 0), 5, 5)
  25. .release().perform();
  26. // Assert only those are selected.
  27. assertTrue("Row 3 should be selected", grid.getRow(3).isSelected());
  28. assertTrue("Row 2 should be selected", grid.getRow(2).isSelected());
  29. assertFalse("Row 4 should not be selected",
  30. grid.getRow(4).isSelected());
  31. assertFalse("Row 1 should not be selected",
  32. grid.getRow(1).isSelected());
  33. }
  34. }