diff options
author | Mehdi Javan <32511762+mehdi-vaadin@users.noreply.github.com> | 2018-09-19 09:20:04 +0300 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2018-09-19 09:20:04 +0300 |
commit | 269ce1beac0fb164cada94342654e96ccfe0425f (patch) | |
tree | b3900abbd88c1563b8e1ab97271bad75017312db /uitest/src/test/java | |
parent | 663f12b7f6b6da213ce94c48aef1e789669eb22a (diff) | |
download | vaadin-framework-269ce1beac0fb164cada94342654e96ccfe0425f.tar.gz vaadin-framework-269ce1beac0fb164cada94342654e96ccfe0425f.zip |
Fix/focus inside window chrome (#11142)
Fixes #11087
Diffstat (limited to 'uitest/src/test/java')
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/window/InitialFocusTest.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/InitialFocusTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/InitialFocusTest.java new file mode 100644 index 0000000000..a6ab48803c --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/window/InitialFocusTest.java @@ -0,0 +1,54 @@ +package com.vaadin.tests.components.window; + +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +public class InitialFocusTest extends MultiBrowserTest { + /** + * To test an implementation of + * {@code com.google.gwt.user.client.ui.Focusable} which is nameField of + * TextField type + */ + @Test + public void window_callingFocusNameField_nameFieldShouldGetFocused() { + openTestURL(); + WebElement openWindowButton = findElement( + By.id(InitialFocus.FOCUS_NAME_BUTTON_ID)); + openWindowButton.click(); + waitForElementPresent(By.id(InitialFocus.NAME_FIELD_ID)); + WebElement focusedElement = getFocusedElement(); + Assert.assertNotNull( + "Name TextField should have focus while focusedElement is null.", + focusedElement); + String focusedElementId = focusedElement.getAttribute("id"); + Assert.assertEquals( + "Name TextField should have focus while " + focusedElementId + + " has focus.", + InitialFocus.NAME_FIELD_ID, focusedElementId); + } + + /** + * To test an implementation of {@code com.vaadin.client.Focusable} which is + * genderField of ComboBox type + */ + @Test + public void window_callingFocusGenderField_genderFieldShouldGetFocused() { + openTestURL(); + WebElement openWindowButton = findElement( + By.id(InitialFocus.FOCUS_GENDER_BUTTON_ID)); + openWindowButton.click(); + waitForElementPresent(By.id(InitialFocus.GENDER_FIELD_ID)); + WebElement focusedElement = getFocusedElement(); + Assert.assertNotNull( + "Gender ComboBox should have focus while focusedElement is null.", + focusedElement); + ComboBoxElement genderField = $(ComboBoxElement.class).first(); + Assert.assertEquals( + "Gender ComboBox should have focus while another element has focus.", + genderField.getInputField(), focusedElement); + } +} |