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.

FocusTest.java 1008B

1234567891011121314151617181920212223242526272829303132
  1. package com.vaadin.tests.components;
  2. import static org.junit.Assert.assertNotNull;
  3. import static org.junit.Assert.assertTrue;
  4. import java.util.List;
  5. import org.openqa.selenium.By;
  6. import org.openqa.selenium.WebElement;
  7. import org.openqa.selenium.remote.DesiredCapabilities;
  8. import com.vaadin.testbench.TestBenchElement;
  9. import com.vaadin.tests.tb3.MultiBrowserTest;
  10. public abstract class FocusTest extends MultiBrowserTest {
  11. protected boolean isFocusInsideElement(TestBenchElement element) {
  12. WebElement focused = getFocusedElement();
  13. assertNotNull(focused);
  14. String id = focused.getAttribute("id");
  15. assertTrue("Focused element should have a non-empty id",
  16. id != null && !"".equals(id));
  17. return element.isElementPresent(By.id(id));
  18. }
  19. @Override
  20. public List<DesiredCapabilities> getBrowsersToTest() {
  21. // Focus does not move when expected with Selenium/TB and Firefox 45
  22. return getBrowsersExcludingFirefox();
  23. }
  24. }