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.

FocusOutsideWindowTest.java 1.1KB

1234567891011121314151617181920212223242526272829303132
  1. package com.vaadin.tests;
  2. import com.vaadin.testbench.elements.TextFieldElement;
  3. import com.vaadin.testbench.elements.WindowElement;
  4. import com.vaadin.tests.tb3.MultiBrowserTest;
  5. import org.junit.Test;
  6. import org.openqa.selenium.By;
  7. import org.openqa.selenium.WebElement;
  8. import static org.junit.Assert.assertEquals;
  9. public class FocusOutsideWindowTest extends MultiBrowserTest {
  10. @Test
  11. public void verifyTextFieldFocused() throws Exception {
  12. openTestURL();
  13. WebElement openW = findElement(By.id("buttonOp"));
  14. WebElement focusBut = findElement(By.id("focusBut"));
  15. // Closing window should focus TexField
  16. openW.click();
  17. TextFieldElement textField = $(TextFieldElement.class).first();
  18. WindowElement window = $(WindowElement.class).first();
  19. window.close();
  20. assertEquals(textField.getWrappedElement(), getFocusedElement());
  21. // Closing window should focus button back(default behaviour)
  22. focusBut.click();
  23. openW.click();
  24. $(WindowElement.class).first().close();
  25. Thread.sleep(150);
  26. assertEquals(openW, getFocusedElement());
  27. }
  28. }