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.

FocusOnSelectedItemTest.java 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.vaadin.tests.components.table;
  2. import static org.junit.Assert.assertTrue;
  3. import org.junit.Test;
  4. import org.openqa.selenium.WebElement;
  5. import com.vaadin.testbench.By;
  6. import com.vaadin.testbench.elements.ButtonElement;
  7. import com.vaadin.testbench.elements.TableElement;
  8. import com.vaadin.tests.tb3.MultiBrowserTest;
  9. /**
  10. * Test to see if the correct row gets the focus when the row is selected from
  11. * the serverside and forces the table to scroll down
  12. *
  13. * @author Vaadin Ltd
  14. */
  15. public class FocusOnSelectedItemTest extends MultiBrowserTest {
  16. @Test
  17. public void selectAndScrollFocusesSelectedRow() {
  18. openTestURL();
  19. WebElement selectButton = $(ButtonElement.class).caption("Select")
  20. .first();
  21. selectButton.click();
  22. WebElement supposedlyFocusedRow = null;
  23. WebElement selectedRow = null;
  24. WebElement focusedStyleRow = null;
  25. assertTrue("No row was selected",
  26. isElementPresent(By.className("v-selected")));
  27. selectedRow = getDriver().findElement(By.className("v-selected"));
  28. supposedlyFocusedRow = $(TableElement.class).first().getCell(198, 0);
  29. assertTrue("Incorrect row was selected", selectedRow.getLocation()
  30. .getY() == supposedlyFocusedRow.getLocation().getY());
  31. assertTrue("No row had the focused style.",
  32. isElementPresent(By.className("v-table-focus")));
  33. focusedStyleRow = getDriver()
  34. .findElement(By.className("v-table-focus"));
  35. assertTrue("Incorrect row has the focused style.", selectedRow
  36. .getLocation().getY() == focusedStyleRow.getLocation().getY());
  37. }
  38. }