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.

GridMultiSelectionOnInitTest.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package com.vaadin.tests.components.grid;
  2. import static org.hamcrest.MatcherAssert.assertThat;
  3. import static org.hamcrest.core.Is.is;
  4. import static org.junit.Assert.assertFalse;
  5. import static org.junit.Assert.assertTrue;
  6. import java.io.IOException;
  7. import org.junit.Test;
  8. import org.openqa.selenium.By;
  9. import org.openqa.selenium.WebElement;
  10. import org.openqa.selenium.interactions.Actions;
  11. import com.vaadin.testbench.elements.GridElement;
  12. import com.vaadin.testbench.elements.ButtonElement;
  13. import com.vaadin.testbench.parallel.TestCategory;
  14. import com.vaadin.tests.tb3.MultiBrowserTest;
  15. @TestCategory("grid")
  16. public class GridMultiSelectionOnInitTest extends MultiBrowserTest {
  17. @Test
  18. public void testSelectAllCheckBoxExists() {
  19. openTestURL();
  20. assertTrue("The select all checkbox was missing.",
  21. $(GridElement.class).first().getHeaderCell(0, 0)
  22. .isElementPresent(By.tagName("input")));
  23. }
  24. @Test
  25. public void selectAllCellCanBeClicked() throws IOException {
  26. openTestURL();
  27. GridElement.GridCellElement selectAllCell = $(GridElement.class).first()
  28. .getHeaderCell(0, 0);
  29. new Actions(getDriver()).moveToElement(selectAllCell, 2, 2).click()
  30. .perform();
  31. WebElement selectAllCheckbox = selectAllCell
  32. .findElement(By.cssSelector("input"));
  33. assertThat(selectAllCheckbox.isSelected(), is(true));
  34. }
  35. @Test
  36. public void testSetSelectedUpdatesClient() {
  37. openTestURL();
  38. assertFalse("Rows should not be selected initially.",
  39. $(GridElement.class).first().getRow(0).isSelected());
  40. $(ButtonElement.class).first().click();
  41. assertTrue("Rows should be selected after button click.",
  42. $(GridElement.class).first().getRow(0).isSelected());
  43. }
  44. @Test
  45. public void testInitialSelection() {
  46. openTestURL("initialSelection=yes");
  47. assertTrue("Initial selection should be visible",
  48. $(GridElement.class).first().getRow(1).isSelected());
  49. }
  50. }