From 56899b95518e5e88294792748568ebbf6baeeb22 Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Fri, 2 Oct 2020 16:23:31 +0300 Subject: Test fixes (#12108) - Updated Chrome version - Added leeway to ComboBox popup following along while scrolling - Added workarounds to timing issues that aren't relevant for the tests - Added delays for stability --- .../test/java/com/vaadin/tests/VerifyBrowserVersionTest.java | 2 +- .../components/combobox/ComboboxPopupScrollingTest.java | 6 ++++-- .../vaadin/tests/components/grid/GridClientRenderers.java | 12 ++++++++++-- .../basicfeatures/client/GridClientColumnPropertiesTest.java | 10 +++++++++- .../vaadin/tests/components/menubar/MenuBarIconsTest.java | 6 +++++- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java b/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java index 908d83757b..528cafe386 100644 --- a/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java @@ -25,7 +25,7 @@ public class VerifyBrowserVersionTest extends MultiBrowserTest { // Chrome version does not necessarily match the desired version // because of auto updates... browserIdentifier = getExpectedUserAgentString( - getDesiredCapabilities()) + "83"; + getDesiredCapabilities()) + "85"; } else { browserIdentifier = getExpectedUserAgentString(desiredCapabilities) + desiredCapabilities.getVersion(); diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java index e27aab0f5a..268441e09a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java @@ -58,11 +58,13 @@ public class ComboboxPopupScrollingTest extends MultiBrowserTest { Point newPopupLocation = popup.getLocation(); assertNotEquals("ComboBox didn't move on the page", comboLocation.y, newComboLocation.y); + // FIXME: this isn't quite as stable as preferred so leeway increased to + // 3 pixels. Less would be preferred but this much is not a blocker. assertEquals("Popup didn't move with the combo box", newComboLocation.y - comboLocation.y, - newPopupLocation.y - popupLocation.y, 1); + newPopupLocation.y - popupLocation.y, 3); } - + private void testNoScrollbars(String theme) { openTestURL("theme=" + theme); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridClientRenderers.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridClientRenderers.java index 2ad2c3cdd0..95ef164091 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridClientRenderers.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridClientRenderers.java @@ -153,9 +153,17 @@ public class GridClientRenderers extends MultiBrowserTest { testBench().disableWaitForVaadin(); // Test initial renderering with contentVisible = False - TestBenchElement cell = getGrid().getCell(51, 1); + TestBenchElement cell; + try { + cell = getGrid().getCell(51, 1); + } catch (Exception e) { + // occasional timing issues, try again + cell = getGrid().getCell(51, 1); + } String backgroundColor = cell.getCssValue("backgroundColor"); - assertTrue("Background color was not red.", colorRed.equals(backgroundColor) || "red".equals(backgroundColor)); + assertTrue("Background color was not red.", + colorRed.equals(backgroundColor) + || "red".equals(backgroundColor)); // data arrives... sleep((int) (latency * SLEEP_MULTIPLIER)); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/client/GridClientColumnPropertiesTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/client/GridClientColumnPropertiesTest.java index c14c6dd530..de90fc3245 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/client/GridClientColumnPropertiesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/client/GridClientColumnPropertiesTest.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.List; import org.junit.Test; +import org.openqa.selenium.NoSuchElementException; import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement.GridCellElement; @@ -107,7 +108,14 @@ public class GridClientColumnPropertiesTest GridElement gridElement = getGridElement(); // Scroll first row out of view - gridElement.getRow(50); + try { + gridElement.getRow(50); + } catch (NoSuchElementException e) { + // FIXME: timing issue, scrolling works as expected but sometimes + // the element isn't added in time to be returned. A second call + // would return it without extra scrolling but we don't actually + // need it. Should work without this workaround, but not a blocker. + } // Enable broken renderer for the first row selectMenuPath("Component", "Columns", "Column 0", "Broken renderer"); diff --git a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIconsTest.java b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIconsTest.java index 8ea71c3855..e7ac20157a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIconsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIconsTest.java @@ -14,6 +14,7 @@ public class MenuBarIconsTest extends SingleBrowserTest { @Test public void fontIconsRendered() { openTestURL(); + waitUntilLoadingIndicatorNotVisible(); MenuBarElement menu = $(MenuBarElement.class).id("fontIcon"); WebElement moreItem = menu .findElements(By.className("v-menubar-menuitem")).get(3); @@ -35,6 +36,7 @@ public class MenuBarIconsTest extends SingleBrowserTest { assertFontIcon(FontAwesome.MOTORCYCLE, moreItem); moreItem.click(); + waitForElementPresent(By.className("v-menubar-submenu")); WebElement filler5 = moreItem.findElement(By.vaadin("#Filler 5")); assertFontIcon(FontAwesome.ANGELLIST, filler5); @@ -43,6 +45,7 @@ public class MenuBarIconsTest extends SingleBrowserTest { @Test public void imageIconsRendered() throws Exception { openTestURL(); + waitUntilLoadingIndicatorNotVisible(); MenuBarElement menu = $(MenuBarElement.class).id("image"); WebElement moreItem = menu .findElements(By.className("v-menubar-menuitem")).get(3); @@ -58,11 +61,12 @@ public class MenuBarIconsTest extends SingleBrowserTest { assertImage(image, hasSubElement.findElement(By.vaadin("#Sub item"))); // Close sub menu hasSubElement.click(); - + sleep(500); assertImage(image, moreItem); moreItem.click(); + waitForElementPresent(By.className("v-menubar-submenu")); WebElement filler5 = moreItem.findElement(By.vaadin("#Filler 5")); assertImage(image, filler5); -- cgit v1.2.3