From: Anna Koskinen Date: Mon, 17 May 2021 10:27:50 +0000 (+0300) Subject: Test tweaks (#12287) (#12302) X-Git-Tag: 8.13.1~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dbb22260347a3606bca9b9b2bd0cf1118baef728;p=vaadin-framework.git Test tweaks (#12287) (#12302) --- diff --git a/uitest/reference-screenshots/chrome/GridLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png b/uitest/reference-screenshots/chrome/GridLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png index fe5f261b93..0efd65d944 100644 Binary files a/uitest/reference-screenshots/chrome/GridLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png and b/uitest/reference-screenshots/chrome/GridLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png differ diff --git a/uitest/reference-screenshots/chrome/HIconTest-LayoutIcon_ANY_Chrome__icon-scrolled.png b/uitest/reference-screenshots/chrome/HIconTest-LayoutIcon_ANY_Chrome__icon-scrolled.png index 4f01ef13bf..71a69d3e8f 100644 Binary files a/uitest/reference-screenshots/chrome/HIconTest-LayoutIcon_ANY_Chrome__icon-scrolled.png and b/uitest/reference-screenshots/chrome/HIconTest-LayoutIcon_ANY_Chrome__icon-scrolled.png differ diff --git a/uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-End.png b/uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-End.png index c84a5ce01f..1e977ff969 100644 Binary files a/uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-End.png and b/uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-End.png differ diff --git a/uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-Middle.png b/uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-Middle.png index 0a03df9b48..8d52c59b44 100644 Binary files a/uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-Middle.png and b/uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-Middle.png differ diff --git a/uitest/reference-screenshots/chrome/VAlignmentTest-layoutAlignment_ANY_Chrome__alignment-scrolled.png b/uitest/reference-screenshots/chrome/VAlignmentTest-layoutAlignment_ANY_Chrome__alignment-scrolled.png index 841d2e1ead..e76e130184 100644 Binary files a/uitest/reference-screenshots/chrome/VAlignmentTest-layoutAlignment_ANY_Chrome__alignment-scrolled.png and b/uitest/reference-screenshots/chrome/VAlignmentTest-layoutAlignment_ANY_Chrome__alignment-scrolled.png differ diff --git a/uitest/reference-screenshots/chrome/VLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png b/uitest/reference-screenshots/chrome/VLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png index ca57d1ed1e..7eb204738c 100644 Binary files a/uitest/reference-screenshots/chrome/VLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png and b/uitest/reference-screenshots/chrome/VLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png differ diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutClickListeners.java b/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutClickListeners.java index 485c79e72a..2e916312cc 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutClickListeners.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutClickListeners.java @@ -125,7 +125,9 @@ public class TestLayoutClickListeners extends AbstractReindeerTestUIWithLog { gl.addComponent(l); } for (int i = nr; i < nr * 2; i++) { - gl.addComponent(new TextField("This is tf" + i, "this is tf " + i)); + TextField tf = new TextField("This is tf" + i, "this is tf " + i); + tf.setWidth("130px"); + gl.addComponent(tf); } } 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 9296e20f84..642a6c7a39 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 @@ -29,10 +29,9 @@ public class DateTimeFieldEventOrderTest extends SingleBrowserTest { .findElements(By.tagName("select")); Select select = new Select(timeSelects.get(0)); + // select two different times to ensure a value change happens select.selectByValue("09"); - // selecting is flaky, try index selection too to ensure selection - // actually happens - select.selectByIndex(9); + select.selectByValue("08"); findElement(By.id("test-button")).click(); waitUntil(new ExpectedCondition() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditRowTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditRowTest.java index 044cff0a4f..924937c78b 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditRowTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditRowTest.java @@ -52,8 +52,9 @@ public class GridEditRowTest extends MultiBrowserTest { private void assertEditorWithinGrid() { GridEditorElement editor = grid.getEditor(); - assertThat(editor.getLocation().y + editor.getSize().height, - not(greaterThan(grid.getLocation().y + grid.getSize().height))); + // allow 1px leeway + assertThat(editor.getLocation().y + editor.getSize().height, not( + greaterThan(grid.getLocation().y + grid.getSize().height + 1))); } @Test diff --git a/uitest/src/test/java/com/vaadin/tests/layouts/UpdateComponentWithinExpandRatioTest.java b/uitest/src/test/java/com/vaadin/tests/layouts/UpdateComponentWithinExpandRatioTest.java index cd12153257..c1b0bbd311 100644 --- a/uitest/src/test/java/com/vaadin/tests/layouts/UpdateComponentWithinExpandRatioTest.java +++ b/uitest/src/test/java/com/vaadin/tests/layouts/UpdateComponentWithinExpandRatioTest.java @@ -23,9 +23,10 @@ public class UpdateComponentWithinExpandRatioTest extends MultiBrowserTest { button.click(); waitUntilLoadingIndicatorNotVisible(); + // allow small discrepancies assertEquals("Button's position changed unexpectedly", initialX, - button.getLocation().getX()); + button.getLocation().getX(), 5); assertEquals("ProgressBar's width changed unexpectedly", initialWidth, - pb.getSize().getWidth()); + pb.getSize().getWidth(), 5); } } diff --git a/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java b/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java index 2032694c19..2a88555208 100644 --- a/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java @@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.List; -import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.JavascriptExecutor; import com.vaadin.testbench.elements.CheckBoxElement; import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest; @@ -23,7 +23,9 @@ public class GridLayoutRegErrorTest extends BaseLayoutRegErrorTest { assertEquals(3, checkBoxes.size()); CheckBoxElement lastCheckBox = checkBoxes.get(2); - new Actions(driver).moveToElement(lastCheckBox).build().perform(); + // moveToElement fails on Firefox since the component is out of viewport + ((JavascriptExecutor) driver).executeScript( + "arguments[0].scrollIntoView(true);", lastCheckBox); compareScreen("RegError-Scrolled"); } diff --git a/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java b/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java index eb0e05b9ec..dccd1362de 100644 --- a/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java +++ b/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java @@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.List; -import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.JavascriptExecutor; import com.vaadin.testbench.elements.HorizontalLayoutElement; import com.vaadin.tests.layouts.layouttester.BaseIconTest; @@ -25,9 +25,12 @@ public class HIconTest extends BaseIconTest { HorizontalLayoutElement lastOfRow1 = layouts.get(3); HorizontalLayoutElement lastOfRow2 = layouts.get(7); - // scroll to both to ensure both contents are fully in view - new Actions(driver).moveToElement(lastOfRow1).build().perform(); - new Actions(driver).moveToElement(lastOfRow2).build().perform(); + // scroll to both to ensure both contents are fully in view, + // moveToElement fails on Firefox since the component is out of viewport + ((JavascriptExecutor) driver).executeScript( + "arguments[0].scrollIntoView(true);", lastOfRow1); + ((JavascriptExecutor) driver).executeScript( + "arguments[0].scrollIntoView(true);", lastOfRow2); compareScreen("icon-scrolled"); } diff --git a/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java b/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java index fdd54c0fe0..b13c8e22e7 100644 --- a/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java @@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.List; -import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.JavascriptExecutor; import com.vaadin.testbench.elements.HorizontalLayoutElement; import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest; @@ -29,18 +29,25 @@ public class HLayoutRegErrorTest extends BaseLayoutRegErrorTest { HorizontalLayoutElement lastOfRow1 = layouts.get(4); HorizontalLayoutElement lastOfRow2 = layouts.get(9); - // scroll to both to ensure both contents are fully in view - new Actions(driver).moveToElement(group3row1).build().perform(); - new Actions(driver).moveToElement(group3row2).build().perform(); + // scroll to both to ensure both contents are fully in view, + // moveToElement fails on Firefox since the component is out of viewport + ((JavascriptExecutor) driver).executeScript( + "arguments[0].scrollIntoView(true);", group3row1); + ((JavascriptExecutor) driver).executeScript( + "arguments[0].scrollIntoView(true);", group3row2); // scroll back to get the previous group at the left edge - new Actions(driver).moveToElement(group2row1).build().perform(); - new Actions(driver).moveToElement(group2row2).build().perform(); + ((JavascriptExecutor) driver).executeScript( + "arguments[0].scrollIntoView(true);", group2row1); + ((JavascriptExecutor) driver).executeScript( + "arguments[0].scrollIntoView(true);", group2row2); compareScreen("RegError-Scrolled-Middle"); // scroll to last ones - new Actions(driver).moveToElement(lastOfRow1).build().perform(); - new Actions(driver).moveToElement(lastOfRow2).build().perform(); + ((JavascriptExecutor) driver).executeScript( + "arguments[0].scrollIntoView(true);", lastOfRow1); + ((JavascriptExecutor) driver).executeScript( + "arguments[0].scrollIntoView(true);", lastOfRow2); compareScreen("RegError-Scrolled-End"); } diff --git a/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java b/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java index d8ab553b7e..693b6f0de9 100644 --- a/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java @@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.List; -import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.JavascriptExecutor; import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.tests.layouts.layouttester.BaseAlignmentTest; @@ -23,7 +23,9 @@ public class VAlignmentTest extends BaseAlignmentTest { assertEquals(9, textFields.size()); TextFieldElement lastTextField = textFields.get(8); - new Actions(driver).moveToElement(lastTextField).build().perform(); + // moveToElement fails on Firefox since the component is out of viewport + ((JavascriptExecutor) driver).executeScript( + "arguments[0].scrollIntoView(true);", lastTextField); compareScreen("alignment-scrolled"); } diff --git a/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java b/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java index eac1dbe31b..32b067b479 100644 --- a/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java @@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.List; -import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.JavascriptExecutor; import com.vaadin.testbench.elements.CheckBoxElement; import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest; @@ -23,7 +23,9 @@ public class VLayoutRegErrorTest extends BaseLayoutRegErrorTest { assertEquals(3, checkBoxes.size()); CheckBoxElement lastCheckBox = checkBoxes.get(2); - new Actions(driver).moveToElement(lastCheckBox).build().perform(); + // moveToElement fails on Firefox since the component is out of viewport + ((JavascriptExecutor) driver).executeScript( + "arguments[0].scrollIntoView(true);", lastCheckBox); compareScreen("RegError-Scrolled"); } diff --git a/uitest/src/test/java/com/vaadin/tests/themes/valo/ResponsiveStylesTest.java b/uitest/src/test/java/com/vaadin/tests/themes/valo/ResponsiveStylesTest.java index b8b376cff4..96886382e6 100644 --- a/uitest/src/test/java/com/vaadin/tests/themes/valo/ResponsiveStylesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/themes/valo/ResponsiveStylesTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.themes.valo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.closeTo; import static org.hamcrest.Matchers.equalTo; import java.util.List; @@ -51,7 +52,7 @@ public class ResponsiveStylesTest extends MultiBrowserTest { WebElement wideMenu = menus.get(WIDE_ELEMENT_INDEX); int wideWidth = wideMenu.getSize().width; - assertThat(wideWidth, equalTo(WIDE_WIDTH)); + assertThat((double) wideWidth, closeTo(WIDE_WIDTH, 1)); sleep(300); compareScreen("defaultMenuWidths"); diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridClientRenderers.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridClientRenderers.java index bb714c598b..71ba4c6251 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridClientRenderers.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridClientRenderers.java @@ -147,7 +147,7 @@ public class GridClientRenderers extends MultiBrowserTest { // Test initial renderering with contentVisible = False TestBenchElement cell = getGrid().getCell(51, 1); - String backgroundColor = cell.getCssValue("backgroundColor"); + String backgroundColor = cell.getCssValue("background-color"); assertEquals("Background color was not red.", colorRed, backgroundColor); @@ -156,7 +156,7 @@ public class GridClientRenderers extends MultiBrowserTest { // Content becomes visible cell = getGrid().getCell(51, 1); - backgroundColor = cell.getCssValue("backgroundColor"); + backgroundColor = cell.getCssValue("background-color"); assertNotEquals("Background color was red.", colorRed, backgroundColor); // scroll down, new cells becomes contentVisible = False @@ -164,7 +164,7 @@ public class GridClientRenderers extends MultiBrowserTest { // Cell should be red (setContentVisible set cell red) cell = getGrid().getCell(55, 1); - backgroundColor = cell.getCssValue("backgroundColor"); + backgroundColor = cell.getCssValue("background-color"); assertEquals("Background color was not red.", colorRed, backgroundColor); @@ -172,7 +172,7 @@ public class GridClientRenderers extends MultiBrowserTest { sleep((int) (latency * SLEEP_MULTIPLIER)); // Cell should no longer be red - backgroundColor = cell.getCssValue("backgroundColor"); + backgroundColor = cell.getCssValue("background-color"); assertTrue("Background color was not reset: " + backgroundColor, backgroundColor.equals(colorWhite) || backgroundColor.equals(colorDark)); diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java index aa0618809b..dccd47e4f2 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java @@ -223,7 +223,8 @@ public abstract class GridBasicFeaturesTest extends MultiBrowserTest { if (dragHeaderCell.findElements(By.className("gwt-HTML")).isEmpty()) { // no selectable header caption, drag freely new Actions(getDriver()).clickAndHold(dragHeaderCell) - .moveToElement(targetHeaderCell, horizontalOffset, 0) + .moveToElement(targetHeaderCell, + getXOffset(targetHeaderCell, horizontalOffset), 0) .release().perform(); } else { // avoid clicking on the caption or the text gets selected and the @@ -234,7 +235,8 @@ public abstract class GridBasicFeaturesTest extends MultiBrowserTest { .moveToElement(dragHeaderCaption, dragHeaderCaption.getSize().getWidth() + 5, 5) .clickAndHold() - .moveToElement(targetHeaderCell, horizontalOffset, 0) + .moveToElement(targetHeaderCell, + getXOffset(targetHeaderCell, horizontalOffset), 0) .release().perform(); } } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java index d07222e35d..400fcd718e 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java @@ -342,7 +342,10 @@ public class GridColumnReorderTest extends GridBasicFeaturesTest { GridCellElement draggedHeaderCell = getGridElement().getHeaderCell(0, 1); final int xOffset = 500; - new Actions(getDriver()).moveToElement(draggedHeaderCell, 20, 10) + new Actions(getDriver()) + .moveToElement(draggedHeaderCell, + getXOffset(draggedHeaderCell, 20), + getYOffset(draggedHeaderCell, 10)) .clickAndHold().moveByOffset(xOffset, 0).build().perform(); WebElement floatingDragElement = findElement( diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeItemDoubleClickTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeItemDoubleClickTest.java index 4b3a48c47f..c3b1151553 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeItemDoubleClickTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeItemDoubleClickTest.java @@ -49,7 +49,8 @@ public class TreeItemDoubleClickTest extends MultiBrowserTest { } private void doubleClick(WebElement element) { - new Actions(getDriver()).doubleClick(element).build().perform(); + new Actions(getDriver()).moveToElement(element).doubleClick().build() + .perform(); sleep(100); }