From: Anna Koskinen Date: Mon, 17 May 2021 10:17:02 +0000 (+0300) Subject: Attempts to reduce test flakiness (#12283) (#12300) X-Git-Tag: 8.13.1~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fb43e9112cb1d6596f2c47a34c0d8968df9e421b;p=vaadin-framework.git Attempts to reduce test flakiness (#12283) (#12300) --- diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldEventOrderTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldEventOrderTest.java index c68bc81252..9296e20f84 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldEventOrderTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldEventOrderTest.java @@ -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() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java index 63ab353d81..75107150c0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java @@ -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")); diff --git a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationMouseTest.java b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationMouseTest.java index 1824ba086b..d32d304bee 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationMouseTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationMouseTest.java @@ -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(); + } }