From: Anna Koskinen Date: Mon, 17 May 2021 11:23:54 +0000 (+0300) Subject: Fix TabSheetElement clicks for IE, test tweaks. (#12291) (#12305) X-Git-Tag: 8.13.1~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fd2af141785dc5128880a25969dc8f36eac2b6e9;p=vaadin-framework.git Fix TabSheetElement clicks for IE, test tweaks. (#12291) (#12305) - 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. --- 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 new file mode 100644 index 0000000000..47a250a2ea Binary files /dev/null and b/uitest/reference-screenshots/firefox/GridLayoutRegErrorTest-LayoutRegError_ANY_Firefox__RegError-Scrolled.png differ 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 new file mode 100644 index 0000000000..7fa56d809e Binary files /dev/null and b/uitest/reference-screenshots/firefox/VLayoutRegErrorTest-LayoutRegError_ANY_Firefox__RegError-Scrolled.png differ 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 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); + } + }