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.

TableDropIndicatorValoTest.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package com.vaadin.tests.components.table;
  2. import java.util.List;
  3. import org.junit.Test;
  4. import org.openqa.selenium.By;
  5. import org.openqa.selenium.WebElement;
  6. import org.openqa.selenium.interactions.Actions;
  7. import com.vaadin.testbench.Parameters;
  8. import com.vaadin.testbench.elements.TableElement;
  9. import com.vaadin.tests.tb3.MultiBrowserTest;
  10. /**
  11. * Tests that clicking on active fields doesn't change Table selection, nor does
  12. * dragging rows.
  13. *
  14. * @author Vaadin Ltd
  15. */
  16. public class TableDropIndicatorValoTest extends MultiBrowserTest {
  17. @Override
  18. public void setup() throws Exception {
  19. super.setup();
  20. openTestURL();
  21. }
  22. @Test
  23. public void indicator() throws Exception {
  24. dragRowWithoutDropping(1);
  25. Parameters.setScreenshotComparisonTolerance(0.1);
  26. compareScreen("indicator");
  27. }
  28. private List<WebElement> getCellContents(WebElement row) {
  29. return row.findElements(By.className("v-table-cell-content"));
  30. }
  31. private List<WebElement> getRows() {
  32. return getTable().findElement(By.className("v-table-body"))
  33. .findElements(By.tagName("tr"));
  34. }
  35. private TableElement getTable() {
  36. return $(TableElement.class).first();
  37. }
  38. private void dragRowWithoutDropping(int from) {
  39. List<WebElement> rows = getRows();
  40. WebElement row = rows.get(from);
  41. List<WebElement> cellContents = getCellContents(row);
  42. int rowHeight = row.getSize().getHeight();
  43. int halfRowHeight = (int) (rowHeight + 0.5) / 2; // rounded off
  44. int oneAndAHalfRow = rowHeight + halfRowHeight;
  45. new Actions(getDriver()).moveToElement(cellContents.get(1))
  46. .clickAndHold().moveByOffset(0, oneAndAHalfRow).perform();
  47. }
  48. }