]> source.dussan.org Git - vaadin-framework.git/commitdiff
Attempts to reduce test flakiness (#12283)
authorAnna Koskinen <Ansku@users.noreply.github.com>
Mon, 3 May 2021 07:31:31 +0000 (10:31 +0300)
committerGitHub <noreply@github.com>
Mon, 3 May 2021 07:31:31 +0000 (10:31 +0300)
* Attempts to reduce test flakiness

uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldEventOrderTest.java
uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java
uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationMouseTest.java

index c68bc8125239f385c1e8197871ee78c97ba67ec7..9296e20f846acfa7e8f6144b85eba450485311fd 100644 (file)
@@ -30,8 +30,9 @@ public class DateTimeFieldEventOrderTest extends SingleBrowserTest {
 
         Select select = new Select(timeSelects.get(0));
         select.selectByValue("09");
-        // selectByValue is flaky, repeat to ensure selection actually happens
-        select.selectByValue("09");
+        // selecting is flaky, try index selection too to ensure selection
+        // actually happens
+        select.selectByIndex(9);
 
         findElement(By.id("test-button")).click();
         waitUntil(new ExpectedCondition<Boolean>() {
index 63ab353d81abfb7d58fc8d88125ed392b0097617..75107150c05b4612e35a543f0cd1544eaa5013c7 100644 (file)
@@ -50,6 +50,10 @@ public class GridResizeHiddenColumnTest extends MultiBrowserTest {
                 headerCellWidth + dragOffset,
                 headerCells.get(0).getSize().getWidth(), delta);
 
+        // make absolutely certain the mouse isn't pressed anymore before moving
+        // to the context menu
+        new Actions(getDriver()).release().perform();
+
         // Make column 'Last Name' visible
         WebElement menuButton = grid.findElement(By.className("v-contextmenu"))
                 .findElement(By.tagName("button"));
index 1824ba086ba74a81fbc960f28d648b0aaf4f92b3..d32d304beeedf79d7085ed88bcf645089c936db3 100644 (file)
@@ -3,12 +3,16 @@ package com.vaadin.tests.components.menubar;
 import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
+import org.openqa.selenium.interactions.Actions;
 
+import com.vaadin.testbench.elements.LabelElement;
 import com.vaadin.testbench.elements.MenuBarElement;
 import com.vaadin.tests.tb3.MultiBrowserTest;
 
 public class MenuBarNavigationMouseTest extends MultiBrowserTest {
 
+    private LabelElement label;
+
     @Override
     protected Class<?> getUIClass() {
         return MenuBarNavigation.class;
@@ -18,6 +22,10 @@ public class MenuBarNavigationMouseTest extends MultiBrowserTest {
     public void testMenuBarMouseNavigation() throws Exception {
         openTestURL();
         MenuBarElement menuBar = $(MenuBarElement.class).first();
+        label = $(LabelElement.class).first();
+
+        // move to Label to ensure all mouse moves are treated the same
+        resetMousePosition();
 
         // clicks separated to different calls for more informative errors
         menuBar.clickItem("File");
@@ -26,15 +34,25 @@ public class MenuBarNavigationMouseTest extends MultiBrowserTest {
         assertEquals("1. MenuItem File/Export../As PDF... selected",
                 getLogRow(0));
 
+        resetMousePosition();
+
         menuBar.clickItem("Edit");
         menuBar.clickItem("Copy");
         assertEquals("2. MenuItem Edit/Copy selected", getLogRow(0));
 
+        resetMousePosition();
+
         menuBar.clickItem("Help");
         assertEquals("3. MenuItem Help selected", getLogRow(0));
 
+        resetMousePosition();
+
         menuBar.clickItem("File");
         menuBar.clickItem("Exit");
         assertEquals("4. MenuItem File/Exit selected", getLogRow(0));
     }
+
+    private void resetMousePosition() {
+        new Actions(driver).moveToElement(label).perform();
+    }
 }