]> source.dussan.org Git - vaadin-framework.git/commitdiff
Test tweaks (#12287) (#12302)
authorAnna Koskinen <Ansku@users.noreply.github.com>
Mon, 17 May 2021 10:27:50 +0000 (13:27 +0300)
committerGitHub <noreply@github.com>
Mon, 17 May 2021 10:27:50 +0000 (13:27 +0300)
20 files changed:
uitest/reference-screenshots/chrome/GridLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png
uitest/reference-screenshots/chrome/HIconTest-LayoutIcon_ANY_Chrome__icon-scrolled.png
uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-End.png
uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-Middle.png
uitest/reference-screenshots/chrome/VAlignmentTest-layoutAlignment_ANY_Chrome__alignment-scrolled.png
uitest/reference-screenshots/chrome/VLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png
uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutClickListeners.java
uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldEventOrderTest.java
uitest/src/test/java/com/vaadin/tests/components/grid/GridEditRowTest.java
uitest/src/test/java/com/vaadin/tests/layouts/UpdateComponentWithinExpandRatioTest.java
uitest/src/test/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java
uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java
uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java
uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java
uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java
uitest/src/test/java/com/vaadin/tests/themes/valo/ResponsiveStylesTest.java
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridClientRenderers.java
uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java
uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java
uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeItemDoubleClickTest.java

index fe5f261b93f34d6b022740783ea93068f214e578..0efd65d944141313f0d9d22a4c58b9f0a571fa78 100644 (file)
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
index 4f01ef13bf534c7bbdec2da09180b9f7b79671b6..71a69d3e8faf6c9f8e16006576de832f5c1e868a 100644 (file)
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
index c84a5ce01f20ea5e212c7e7dad4dbc076236e106..1e977ff9693acd9b9a941d05bab5865a980cd4d5 100644 (file)
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
index 0a03df9b48cfa91ced58454b8fcb41426ebedc2a..8d52c59b4403d5f2785e17f9957f821243c3d76e 100644 (file)
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
index 841d2e1eadbfd8b2e0fa6a2bc2bb9bb59475948e..e76e130184df49a7c5510b1fa7f2d88ec054492e 100644 (file)
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
index ca57d1ed1eed19f27c6e45a9106395111853b370..7eb204738cf431f60841a00291194abb6e539b8b 100644 (file)
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
index 485c79e72a96a44cb68660c49b7c0512267ddba5..2e916312cc387859eda5ac7112ddb2fe66195874 100644 (file)
@@ -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);
         }
     }
 
index 9296e20f846acfa7e8f6144b85eba450485311fd..642a6c7a3955b40f34f27691e584095cb8257d01 100644 (file)
@@ -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<Boolean>() {
index 044cff0a4f701baa198ce8b65d4eb1e2c0e21217..924937c78b2f786a1c6fd586dce7a167625d8f8b 100644 (file)
@@ -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
index cd12153257a9250bd8e3d283d91fcfcd5c10d5fe..c1b0bbd311e59213c0a0ce7eeace3ac506f059e4 100644 (file)
@@ -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);
     }
 }
index 2032694c19816a8a863259cdaec0154589e66718..2a885552084637799f41485bd85ccd6c4e08f205 100644 (file)
@@ -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");
     }
index eb0e05b9ec07a472a3729eabe6f63e454b977c48..dccd1362de6db47a4c91717c6f33a1a0a8458541 100644 (file)
@@ -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");
     }
index fdd54c0fe0edebf337b04bc6414b387be86a0166..b13c8e22e7653cc97a26d7e7cd51232d6d3591eb 100644 (file)
@@ -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");
     }
index d8ab553b7eecca423af78d078ee9ce2abbb754f0..693b6f0de97eb6e47e4f89f9d3514856f9614605 100644 (file)
@@ -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");
     }
index eac1dbe31b2005bb28e1198cc4aa04c15a2bb650..32b067b479acd0d1156298369ec92be0365f5ea5 100644 (file)
@@ -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");
     }
index b8b376cff40b3350a6cfa4451b7f57dabf6989fe..96886382e62198170e7ab6441b1b721b6628019b 100644 (file)
@@ -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");
index bb714c598b300bd7589d31998d7707f52fec47f5..71ba4c6251fc5797bd2c1190ca1b40dba33b525e 100644 (file)
@@ -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));
index aa0618809b5299d7920c0701207567f5daab567b..dccd47e4f2504609cd725e0b508fcc96a28cc388 100644 (file)
@@ -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();
         }
     }
index d07222e35ddf021d01e0c24ae149076db532a5bd..400fcd718e1c3970dc4d0f2fbdf3a83b185dfc4c 100644 (file)
@@ -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(
index 4b3a48c47fe7c54145b98fd13da7a21018bf4a7b..c3b115155357d5e5c9b0f56c5a7dd32c3b81d36b 100644 (file)
@@ -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);
     }