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.

GridEditorUITest.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package com.vaadin.tests.components.grid;
  2. import static org.hamcrest.CoreMatchers.containsString;
  3. import static org.hamcrest.CoreMatchers.not;
  4. import static org.hamcrest.MatcherAssert.assertThat;
  5. import static org.junit.Assert.assertFalse;
  6. import static org.junit.Assert.assertTrue;
  7. import org.junit.Test;
  8. import org.openqa.selenium.Keys;
  9. import org.openqa.selenium.interactions.Actions;
  10. import com.vaadin.testbench.By;
  11. import com.vaadin.testbench.elements.GridElement;
  12. import com.vaadin.testbench.elements.GridElement.GridCellElement;
  13. import com.vaadin.testbench.elements.NotificationElement;
  14. import com.vaadin.testbench.elements.PasswordFieldElement;
  15. import com.vaadin.testbench.parallel.TestCategory;
  16. import com.vaadin.tests.tb3.MultiBrowserTest;
  17. @TestCategory("grid")
  18. public class GridEditorUITest extends MultiBrowserTest {
  19. @Override
  20. public void setup() throws Exception {
  21. super.setup();
  22. setDebug(true);
  23. openTestURL();
  24. }
  25. private void openEditor(int rowIndex) {
  26. GridElement grid = $(GridElement.class).first();
  27. GridCellElement cell = grid.getCell(rowIndex, 1);
  28. new Actions(driver).moveToElement(cell).doubleClick().build().perform();
  29. }
  30. private void saveEditor() {
  31. findElement(By.cssSelector(".v-grid-editor-save")).click();
  32. }
  33. private GridCellElement getHeaderCell(int rowIndex, int colIndex) {
  34. GridElement grid = $(GridElement.class).first();
  35. GridCellElement headerCell = grid.getHeaderCell(rowIndex, colIndex);
  36. return headerCell;
  37. }
  38. @Test
  39. public void testEditor() {
  40. assertFalse("Sanity check",
  41. isElementPresent(PasswordFieldElement.class));
  42. openEditor(5);
  43. new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform();
  44. openEditor(10);
  45. assertTrue("Editor should be opened with a password field",
  46. isElementPresent(PasswordFieldElement.class));
  47. assertFalse("Notification was present",
  48. isElementPresent(NotificationElement.class));
  49. }
  50. @Test
  51. public void savingResetsSortingIndicator() {
  52. GridCellElement headerCell = getHeaderCell(0, 0);
  53. headerCell.click();
  54. openEditor(1);
  55. saveEditor();
  56. assertThat(headerCell.getAttribute("class"),
  57. not(containsString("sort-")));
  58. }
  59. }