diff options
author | Olli Tietäväinen <ollit@vaadin.com> | 2018-01-24 11:29:10 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2018-01-24 11:29:10 +0200 |
commit | 881d80fd8b658491e26125222020401d0e5a5d08 (patch) | |
tree | 98f5d023118147e0ff70843a023c1de09acc3beb /uitest/src/test/java | |
parent | 2c3df1adfdecdda7747ec63b00ab4a6c5e1315d3 (diff) | |
download | vaadin-framework-881d80fd8b658491e26125222020401d0e5a5d08.tar.gz vaadin-framework-881d80fd8b658491e26125222020401d0e5a5d08.zip |
Make modal window focus circulate correctly (#10497)
Diffstat (limited to 'uitest/src/test/java')
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowFocusTest.java | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowFocusTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowFocusTest.java index 8cbb9d6ae9..b65ff037a6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowFocusTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowFocusTest.java @@ -26,6 +26,7 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -43,8 +44,8 @@ public class ModalWindowFocusTest extends MultiBrowserTest { } /** - * First scenario: press button -> two windows appear, press Esc two times - * -> all windows should be closed + * First scenario: press first button -> two windows appear, press Esc two + * times -> all windows should be closed */ @Test public void testModalWindowFocusTwoWindows() throws IOException { @@ -57,17 +58,17 @@ public class ModalWindowFocusTest extends MultiBrowserTest { assertTrue("Second window should be opened", findElements(By.id("windowButton")).size() == 1); - pressEscAndWait(); - pressEscAndWait(); + pressKeyAndWait(Keys.ESCAPE); + pressKeyAndWait(Keys.ESCAPE); assertTrue("All windows should be closed", findElements(By.className("v-window")).size() == 0); } /** - * Second scenario: press button -> two windows appear, press button in the - * 2nd window -> 3rd window appears on top, press Esc three times -> all - * windows should be closed + * Second scenario: press first button -> two windows appear, press button + * in the 2nd window -> 3rd window appears on top, press Esc three times -> + * all windows should be closed */ @Test public void testModalWindowFocusPressButtonInWindow() throws IOException { @@ -84,14 +85,37 @@ public class ModalWindowFocusTest extends MultiBrowserTest { assertTrue("Third window should be opened", findElements(By.id("window3")).size() == 1); - pressEscAndWait(); - pressEscAndWait(); - pressEscAndWait(); + pressKeyAndWait(Keys.ESCAPE); + pressKeyAndWait(Keys.ESCAPE); + pressKeyAndWait(Keys.ESCAPE); assertTrue("All windows should be closed", findElements(By.className("v-window")).size() == 0); } + /** + * Third scenario: press second button -> a modal unclosable and + * unresizeable window with two text fields opens -> second text field is + * automatically focused -> press tab -> the focus rolls around to the top + * of the modal window -> the first text field is focused and shows a text + */ + @Test + public void testModalWindowWithoutButtonsFocusHandling() { + waitForElementPresent(By.id("modalWindowButton")); + WebElement button = findElement(By.id("modalWindowButton")); + button.click(); + waitForElementPresent(By.id("focusfield")); + pressKeyAndWait(Keys.TAB); + TextFieldElement tfe = $(TextFieldElement.class).id("focusfield"); + assertTrue("First TextField should have received focus", + "this has been focused".equals(tfe.getValue())); + } + + private void pressKeyAndWait(Keys key) { + new Actions(driver).sendKeys(key).build().perform(); + sleep(100); + } + @Test public void verifyAriaModalAndRoleAttributes() { waitForElementPresent(By.id("firstButton")); @@ -107,9 +131,4 @@ public class ModalWindowFocusTest extends MultiBrowserTest { } - private void pressEscAndWait() { - new Actions(driver).sendKeys(Keys.ESCAPE).build().perform(); - sleep(100); - } - } |