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.

LongMultiselectTest.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package com.vaadin.tests.components.table;
  2. import static org.hamcrest.CoreMatchers.is;
  3. import static org.hamcrest.MatcherAssert.assertThat;
  4. import java.util.List;
  5. import org.junit.Test;
  6. import org.openqa.selenium.Keys;
  7. import org.openqa.selenium.interactions.Actions;
  8. import org.openqa.selenium.remote.DesiredCapabilities;
  9. import com.vaadin.testbench.elements.TableElement;
  10. import com.vaadin.testbench.elements.ButtonElement;
  11. import com.vaadin.tests.tb3.MultiBrowserTest;
  12. public class LongMultiselectTest extends MultiBrowserTest {
  13. private int ROWCOUNT = 100;
  14. private int FIRSTSELECTEDROW = 4;
  15. private int LASTSELECTEDROW = 97;
  16. @Override
  17. public List<DesiredCapabilities> getBrowsersToTest() {
  18. return getBrowsersSupportingShiftClick();
  19. }
  20. @Override
  21. protected boolean requireWindowFocusForIE() {
  22. return true;
  23. }
  24. @Test
  25. public void selectedRowsAreUpdated() throws InterruptedException {
  26. openTestURL();
  27. selectRows();
  28. $(ButtonElement.class).first().click();
  29. TableElement table = getTable();
  30. assertThat(table.getCell(LASTSELECTEDROW, 1).getText(), is("updated"));
  31. assertThat(table.getCell(LASTSELECTEDROW - 1, 1).getText(),
  32. is("updated"));
  33. }
  34. private void selectRows() {
  35. TableElement table = getTable();
  36. table.getCell(FIRSTSELECTEDROW, 0).click();
  37. scrollToBottom();
  38. new Actions(getDriver()).keyDown(Keys.SHIFT)
  39. .click(getTable().getCell(LASTSELECTEDROW, 0)).keyUp(Keys.SHIFT)
  40. .build().perform();
  41. }
  42. private TableElement getTable() {
  43. return $(TableElement.class).first();
  44. }
  45. private void scrollToBottom() {
  46. scrollTable(getTable(), ROWCOUNT, LASTSELECTEDROW);
  47. }
  48. }