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.

EditableModeChangeTest.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package com.vaadin.tests.components.table;
  2. import static org.junit.Assert.assertEquals;
  3. import java.io.IOException;
  4. import java.util.List;
  5. import org.junit.Test;
  6. import org.openqa.selenium.By;
  7. import org.openqa.selenium.WebElement;
  8. import org.openqa.selenium.interactions.Actions;
  9. import com.vaadin.testbench.TestBenchElement;
  10. import com.vaadin.testbench.elements.TableElement;
  11. import com.vaadin.tests.tb3.MultiBrowserTest;
  12. /**
  13. * Tests that editing and selecting work correctly.
  14. *
  15. * @author Vaadin Ltd
  16. */
  17. public class EditableModeChangeTest extends MultiBrowserTest {
  18. @Test
  19. public void testNotification() throws IOException, InterruptedException {
  20. openTestURL();
  21. TableElement table = $(TableElement.class).first();
  22. // check original value
  23. TestBenchElement cell_1_0 = table.getCell(1, 0);
  24. assertEquals(
  25. "original value not found, wrong cell or contents (1st column of the 2nd row expected)",
  26. "Teppo", cell_1_0.getText());
  27. // double-click to edit cell contents
  28. cell_1_0.click();
  29. new Actions(getDriver()).doubleClick(cell_1_0).build().perform();
  30. sleep(100);
  31. // fetch the updated cell
  32. WebElement textField = table.getCell(1, 0)
  33. .findElement(By.className("v-textfield"));
  34. assertEquals(
  35. "original value not found, wrong cell or contents (1st column of the 2nd row expected)",
  36. "Teppo", textField.getAttribute("value"));
  37. // update value
  38. textField.clear();
  39. textField.sendKeys("baa");
  40. // click on another row
  41. table.getCell(0, 1).click();
  42. // check the value got updated correctly
  43. assertEquals(
  44. "updated value not found, wrong cell or contents (1st column of the 2nd row expected)",
  45. "baa", table.getCell(1, 0).getText());
  46. // check that selection got updated correctly
  47. List<WebElement> selected = table
  48. .findElement(By.className("v-table-body"))
  49. .findElements(By.className("v-selected"));
  50. assertEquals(1, selected.size());
  51. WebElement content = selected.get(0)
  52. .findElement(By.className("v-table-cell-wrapper"));
  53. assertEquals(
  54. "expected value not found, wrong cell or contents (1st column of the 1st row expected)",
  55. "Teemu", content.getText());
  56. compareScreen("selection");
  57. }
  58. }