]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix TabSheetElement clicks for IE, test tweaks. (#12291) (#12305)
authorAnna Koskinen <Ansku@users.noreply.github.com>
Mon, 17 May 2021 11:23:54 +0000 (14:23 +0300)
committerGitHub <noreply@github.com>
Mon, 17 May 2021 11:23:54 +0000 (14:23 +0300)
- 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.

testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java
uitest/reference-screenshots/firefox/GridLayoutRegErrorTest-LayoutRegError_ANY_Firefox__RegError-Scrolled.png [new file with mode: 0644]
uitest/reference-screenshots/firefox/VLayoutRegErrorTest-LayoutRegError_ANY_Firefox__RegError-Scrolled.png [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/components/tabsheet/ScrolledTabSheetResizeTest.java
uitest/src/test/java/com/vaadin/tests/components/window/BackspaceKeyWithModalOpenedTest.java
uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowRefocusTest.java

index f476867946fc78de2a6878d9580c642329a47349..147e91fc08036ca9db1a2061b2ac3dce5d4115bc 100644 (file)
@@ -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 (file)
index 0000000..47a250a
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 (file)
index 0000000..7fa56d8
Binary files /dev/null and b/uitest/reference-screenshots/firefox/VLayoutRegErrorTest-LayoutRegError_ANY_Firefox__RegError-Scrolled.png differ
index 0390c525091005d2b8f1667b770fb10ff9939f74..4f0ae02b43fd9341ec78425eb9c5889c56e961a1 100644 (file)
@@ -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) {
index 1512042eab5cfbed65b7584d51167f7b5da426ef..c387b43139cba973a1edcd14f19cfe7d0a6136f7 100644 (file)
@@ -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();
     }
index eaf4b7e6a30731da79d4da50e3b32ddb420165c8..8a432962975a6016dc6c24080fd257600fc4b490 100755 (executable)
@@ -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);
+    }
+
 }