diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2021-05-07 11:32:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-07 11:32:07 +0300 |
commit | 4cb4f2d602ce4ef79fb0ff03487047044f18a2f6 (patch) | |
tree | 9157b364231c87c6c1930f5ffca67264273d4a7b | |
parent | 806026070ae953a266a6fff941c1967e4c96cf81 (diff) | |
download | vaadin-framework-4cb4f2d602ce4ef79fb0ff03487047044f18a2f6.tar.gz vaadin-framework-4cb4f2d602ce4ef79fb0ff03487047044f18a2f6.zip |
Fix TabSheetElement clicks for IE, test tweaks. (#12291)
- Backspace navigation hasn't worked in years thanks to new browser
standards, removed related tests. Left a test for regular backspace use
within a modal window.
- Enabled a modal window test for Chrome since it seems to be working
now, removed extending of another test class to avoid running the tests
twice without any configuration changes.
- Adjusted browser width limitation.
- Added screenshots.
6 files changed, 26 insertions, 52 deletions
diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java index f476867946..147e91fc08 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java @@ -26,6 +26,7 @@ import com.vaadin.testbench.TestBench; import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.elementsbase.AbstractElement; import com.vaadin.testbench.elementsbase.ServerClass; +import com.vaadin.testbench.parallel.BrowserUtil; @ServerClass("com.vaadin.ui.TabSheet") public class TabSheetElement extends AbstractComponentContainerElement { @@ -122,7 +123,13 @@ public class TabSheetElement extends AbstractComponentContainerElement { } // If neither text nor icon caption was found, click at a position that // is unlikely to close the tab. - ((TestBenchElement) tabCell).click(-5, 0); + if (BrowserUtil.isIE(getCapabilities())) { + // old default, offset calculated from top left + ((TestBenchElement) tabCell).click(10, 10); + } else { + // w3c compliant, offset calculated from middle + ((TestBenchElement) tabCell).click(-5, 0); + } } /** diff --git a/uitest/reference-screenshots/firefox/GridLayoutRegErrorTest-LayoutRegError_ANY_Firefox__RegError-Scrolled.png b/uitest/reference-screenshots/firefox/GridLayoutRegErrorTest-LayoutRegError_ANY_Firefox__RegError-Scrolled.png Binary files differnew file mode 100644 index 0000000000..47a250a2ea --- /dev/null +++ b/uitest/reference-screenshots/firefox/GridLayoutRegErrorTest-LayoutRegError_ANY_Firefox__RegError-Scrolled.png diff --git a/uitest/reference-screenshots/firefox/VLayoutRegErrorTest-LayoutRegError_ANY_Firefox__RegError-Scrolled.png b/uitest/reference-screenshots/firefox/VLayoutRegErrorTest-LayoutRegError_ANY_Firefox__RegError-Scrolled.png Binary files differnew file mode 100644 index 0000000000..7fa56d809e --- /dev/null +++ b/uitest/reference-screenshots/firefox/VLayoutRegErrorTest-LayoutRegError_ANY_Firefox__RegError-Scrolled.png diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/ScrolledTabSheetResizeTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/ScrolledTabSheetResizeTest.java index 0390c52509..4f0ae02b43 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/ScrolledTabSheetResizeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/ScrolledTabSheetResizeTest.java @@ -63,9 +63,9 @@ public class ScrolledTabSheetResizeTest extends MultiBrowserTest { public void testValo() throws IOException, InterruptedException { StringBuilder exceptions = new StringBuilder(); boolean failed = false; - // upper limit is determined by the amount of tabs (wider than for - // reindeer), lower end by limits set by Selenium version - for (int i = 1550; i >= 650; i = i - 50) { + // 1550 would be better for the amount of tabs (wider than for + // reindeer), but IE11 can't adjust that far + for (int i = 1500; i >= 650; i = i - 50) { try { testResize(i); } catch (Exception e) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/BackspaceKeyWithModalOpenedTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/BackspaceKeyWithModalOpenedTest.java index 1512042eab..c387b43139 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/BackspaceKeyWithModalOpenedTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/BackspaceKeyWithModalOpenedTest.java @@ -4,13 +4,10 @@ import static com.vaadin.tests.components.window.BackspaceKeyWithModalOpened.BTN import static com.vaadin.tests.components.window.BackspaceKeyWithModalOpened.BTN_OPEN_MODAL_ID; import static org.junit.Assert.assertEquals; import static org.openqa.selenium.Keys.BACK_SPACE; -import static org.openqa.selenium.Keys.TAB; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.By; import com.vaadin.testbench.elements.ButtonElement; @@ -34,38 +31,6 @@ public class BackspaceKeyWithModalOpenedTest extends MultiBrowserTest { checkButtonsCount(); } - /** - * Tests that backspace action outside textfield is prevented - */ - @Test - public void testWithFocusOnModal() throws Exception { - // Try to send back actions to the browser. - new Actions(getDriver()).sendKeys(BACK_SPACE).perform(); - - checkButtonsCount(); - } - - /** - * Tests that backspace action in the bottom component is prevented. - * - * Ignored because the fix to #8855 stops the top and bottom components from - * functioning as focus traps. Meanwhile, navigation with Backspace is not - * anymore supported by reasonable browsers. - */ - @Test - @Ignore - public void testWithFocusOnBottom() throws Exception { - TextFieldElement textField = getTextField(); - - // tab in last field set focus on bottom component - textField.sendKeys(TAB); - - // Try to send back actions to the browser. - new Actions(getDriver()).sendKeys(BACK_SPACE).perform(); - - checkButtonsCount(); - } - private TextFieldElement getTextField() { return $(TextFieldElement.class).first(); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowRefocusTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowRefocusTest.java index eaf4b7e6a3..8a43296297 100755 --- a/uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowRefocusTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowRefocusTest.java @@ -1,17 +1,16 @@ package com.vaadin.tests.components.window; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import java.util.List; - import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.By; import com.vaadin.testbench.elements.TextFieldElement; -import com.vaadin.testbench.parallel.Browser; +import com.vaadin.tests.tb3.MultiBrowserTest; /** * Tests that a modal window is focused on creation and that on closing a window @@ -19,14 +18,7 @@ import com.vaadin.testbench.parallel.Browser; * * @author Vaadin Ltd */ -public class ModalWindowRefocusTest extends ModalWindowFocusTest { - - @Override - public List<DesiredCapabilities> getBrowsersToTest() { - // Chrome doesn't support clicking on the modality curtain - return getBrowserCapabilities(Browser.IE11, Browser.EDGE, - Browser.FIREFOX); - } +public class ModalWindowRefocusTest extends MultiBrowserTest { @Override protected Class<?> getUIClass() { @@ -40,10 +32,16 @@ public class ModalWindowRefocusTest extends ModalWindowFocusTest { */ @Test public void testFocusOutsideModal() { + openTestURL(); waitForElementPresent(By.id("modalWindowButton")); WebElement button = findElement(By.id("modalWindowButton")); button.click(); + waitForElementPresent(By.id("focusfield")); + TextFieldElement tfe = $(TextFieldElement.class).id("focusfield"); + assertFalse("First TextField should not have focus", + "this has been focused".equals(tfe.getValue())); + WebElement curtain = findElement( org.openqa.selenium.By.className("v-window-modalitycurtain")); testBenchElement(curtain).click(getXOffset(curtain, 20), @@ -53,10 +51,14 @@ public class ModalWindowRefocusTest extends ModalWindowFocusTest { pressKeyAndWait(Keys.TAB); pressKeyAndWait(Keys.TAB); - TextFieldElement tfe = $(TextFieldElement.class).id("focusfield"); assertTrue("First TextField should have received focus", "this has been focused".equals(tfe.getValue())); } + protected void pressKeyAndWait(Keys key) { + new Actions(driver).sendKeys(key).build().perform(); + sleep(100); + } + } |