diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2021-05-03 10:31:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-03 10:31:31 +0300 |
commit | 6798dff773024fe0b83d0d19d43471ab6d9ef8ae (patch) | |
tree | afe5fa6a26b09e8e9f7e598b1309d747fb2f0645 /uitest | |
parent | 7ca2e1e0d5b69cc8a8237a73e57ce5cc46415c1c (diff) | |
download | vaadin-framework-6798dff773024fe0b83d0d19d43471ab6d9ef8ae.tar.gz vaadin-framework-6798dff773024fe0b83d0d19d43471ab6d9ef8ae.zip |
Attempts to reduce test flakiness (#12283)
* Attempts to reduce test flakiness
Diffstat (limited to 'uitest')
3 files changed, 25 insertions, 2 deletions
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<Boolean>() { 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(); + } } |