diff options
author | Zhe Sun <31067185+ZheSun88@users.noreply.github.com> | 2019-06-12 12:36:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-12 12:36:55 +0300 |
commit | 4665d366472055c2eeb74dc444346b99b3729ecf (patch) | |
tree | a0deece64cf682ea4f2fd23ae458e85c06c83b8d | |
parent | 7a453dce177d849305c549296986eb21e171bae0 (diff) | |
download | vaadin-framework-4665d366472055c2eeb74dc444346b99b3729ecf.tar.gz vaadin-framework-4665d366472055c2eeb74dc444346b99b3729ecf.zip |
Update Chrome version in Test (#11613)
1) recalculate the offset, as ChromeDriver starts to follow the standard;
2) update screenshots;
3) correct the `click()` call with using coordinates, related to 1)
4) `sendkey()` with using key.modifier adjustment
5) add sleep
6) workaround for mastery failures
35 files changed, 145 insertions, 89 deletions
diff --git a/client/src/main/java/com/vaadin/client/widgets/Escalator.java b/client/src/main/java/com/vaadin/client/widgets/Escalator.java index c60358e449..8df0ace3d8 100644 --- a/client/src/main/java/com/vaadin/client/widgets/Escalator.java +++ b/client/src/main/java/com/vaadin/client/widgets/Escalator.java @@ -4669,7 +4669,8 @@ public class Escalator extends Widget double maxWidth = Math.max(headerWidth, Math.max(bodyWidth, footerWidth)); - if (maxWidth < 0 && header.getRowCount() == 0 && body.getRowCount() == 0 && footer.getRowCount() == 0) { + if (maxWidth < 0 && header.getRowCount() == 0 + && body.getRowCount() == 0 && footer.getRowCount() == 0) { maxWidth = 0; } assert maxWidth >= 0 : "Got a negative max width for a column, which should be impossible."; @@ -4684,7 +4685,8 @@ public class Escalator extends Widget double minWidth = Math.max(headerWidth, Math.max(bodyWidth, footerWidth)); - if (minWidth < 0 && header.getRowCount() == 0 && body.getRowCount() == 0 && footer.getRowCount() == 0) { + if (minWidth < 0 && header.getRowCount() == 0 + && body.getRowCount() == 0 && footer.getRowCount() == 0) { minWidth = 0; } assert minWidth >= 0 : "Got a negative min width for a column, which should be impossible."; diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java index 06e3eb8f99..edbf323c5f 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java @@ -122,7 +122,7 @@ public class TabSheetElement extends AbstractComponentContainerElement { } // If neither text nor icon caption was found, click at a position that // is unlikely to close the tab. - ((TestBenchElement) tabCell).click(10, 10); + ((TestBenchElement) tabCell).click(-5, 0); } /** diff --git a/uitest/reference-screenshots/chrome/BaseThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png b/uitest/reference-screenshots/chrome/BaseThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png Binary files differindex 5060675836..8d958b9e91 100755 --- a/uitest/reference-screenshots/chrome/BaseThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png +++ b/uitest/reference-screenshots/chrome/BaseThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png diff --git a/uitest/reference-screenshots/chrome/ChameleonThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png b/uitest/reference-screenshots/chrome/ChameleonThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png Binary files differindex 8f19dddf89..a8d1b6d5aa 100755 --- a/uitest/reference-screenshots/chrome/ChameleonThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png +++ b/uitest/reference-screenshots/chrome/ChameleonThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png diff --git a/uitest/reference-screenshots/chrome/CtrlShiftMultiselectTest-testSelectionRangeDragging_ANY_Chrome__draggedMultipleRows.png b/uitest/reference-screenshots/chrome/CtrlShiftMultiselectTest-testSelectionRangeDragging_ANY_Chrome__draggedMultipleRows.png Binary files differindex f0d8d2deb9..d438239054 100644 --- a/uitest/reference-screenshots/chrome/CtrlShiftMultiselectTest-testSelectionRangeDragging_ANY_Chrome__draggedMultipleRows.png +++ b/uitest/reference-screenshots/chrome/CtrlShiftMultiselectTest-testSelectionRangeDragging_ANY_Chrome__draggedMultipleRows.png diff --git a/uitest/reference-screenshots/chrome/DragStartModesTest-testDragStartModes_ANY_Chrome__dragImageModeCOMPONENT_OTHER.png b/uitest/reference-screenshots/chrome/DragStartModesTest-testDragStartModes_ANY_Chrome__dragImageModeCOMPONENT_OTHER.png Binary files differindex dd456d5e74..228791208f 100755 --- a/uitest/reference-screenshots/chrome/DragStartModesTest-testDragStartModes_ANY_Chrome__dragImageModeCOMPONENT_OTHER.png +++ b/uitest/reference-screenshots/chrome/DragStartModesTest-testDragStartModes_ANY_Chrome__dragImageModeCOMPONENT_OTHER.png diff --git a/uitest/reference-screenshots/chrome/GridEditorFrozenColumnsUITest-testEditorWithFrozenColumns_ANY_Chrome__noscroll.png b/uitest/reference-screenshots/chrome/GridEditorFrozenColumnsUITest-testEditorWithFrozenColumns_ANY_Chrome__noscroll.png Binary files differindex 89afa7c96e..dfdc316710 100755 --- a/uitest/reference-screenshots/chrome/GridEditorFrozenColumnsUITest-testEditorWithFrozenColumns_ANY_Chrome__noscroll.png +++ b/uitest/reference-screenshots/chrome/GridEditorFrozenColumnsUITest-testEditorWithFrozenColumns_ANY_Chrome__noscroll.png diff --git a/uitest/reference-screenshots/chrome/GridEditorFrozenColumnsUITest-testEditorWithFrozenColumns_ANY_Chrome__scrolled.png b/uitest/reference-screenshots/chrome/GridEditorFrozenColumnsUITest-testEditorWithFrozenColumns_ANY_Chrome__scrolled.png Binary files differindex 12fcdd2246..e427072556 100755 --- a/uitest/reference-screenshots/chrome/GridEditorFrozenColumnsUITest-testEditorWithFrozenColumns_ANY_Chrome__scrolled.png +++ b/uitest/reference-screenshots/chrome/GridEditorFrozenColumnsUITest-testEditorWithFrozenColumns_ANY_Chrome__scrolled.png diff --git a/uitest/reference-screenshots/chrome/LabelTooltipTest-testLabelToolTipChameleonTheme_ANY_Chrome__tooltipVisible.png b/uitest/reference-screenshots/chrome/LabelTooltipTest-testLabelToolTipChameleonTheme_ANY_Chrome__tooltipVisible.png Binary files differindex 2554112d59..2cbcfb76e7 100644 --- a/uitest/reference-screenshots/chrome/LabelTooltipTest-testLabelToolTipChameleonTheme_ANY_Chrome__tooltipVisible.png +++ b/uitest/reference-screenshots/chrome/LabelTooltipTest-testLabelToolTipChameleonTheme_ANY_Chrome__tooltipVisible.png diff --git a/uitest/reference-screenshots/chrome/ReindeerThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png b/uitest/reference-screenshots/chrome/ReindeerThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png Binary files differindex 18c01b359b..bd801d4604 100755 --- a/uitest/reference-screenshots/chrome/ReindeerThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png +++ b/uitest/reference-screenshots/chrome/ReindeerThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png diff --git a/uitest/reference-screenshots/chrome/RunoThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png b/uitest/reference-screenshots/chrome/RunoThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png Binary files differindex 267ffd332e..128276b1af 100755 --- a/uitest/reference-screenshots/chrome/RunoThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png +++ b/uitest/reference-screenshots/chrome/RunoThemeTest-testTheme_ANY_Chrome__tables-contextmenu.png diff --git a/uitest/reference-screenshots/chrome/ThemeChangeOnTheFlyTest-reindeerToOthers_ANY_Chrome__reindeer.png b/uitest/reference-screenshots/chrome/ThemeChangeOnTheFlyTest-reindeerToOthers_ANY_Chrome__reindeer.png Binary files differindex 6b4ff93467..4a637d1b80 100644 --- a/uitest/reference-screenshots/chrome/ThemeChangeOnTheFlyTest-reindeerToOthers_ANY_Chrome__reindeer.png +++ b/uitest/reference-screenshots/chrome/ThemeChangeOnTheFlyTest-reindeerToOthers_ANY_Chrome__reindeer.png diff --git a/uitest/reference-screenshots/chrome/ValoThemeUITest-selects_ANY_Chrome__selects.png b/uitest/reference-screenshots/chrome/ValoThemeUITest-selects_ANY_Chrome__selects.png Binary files differindex 06a9a3e7ff..32158cd04a 100755 --- a/uitest/reference-screenshots/chrome/ValoThemeUITest-selects_ANY_Chrome__selects.png +++ b/uitest/reference-screenshots/chrome/ValoThemeUITest-selects_ANY_Chrome__selects.png diff --git a/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java b/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java index 7ed1ca6991..195b02012b 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()) + "74"; + getDesiredCapabilities()) + "75"; } else if (BrowserUtil.isFirefox(getDesiredCapabilities())) { browserIdentifier = getExpectedUserAgentString( getDesiredCapabilities()) + "58"; diff --git a/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerUserColorChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerUserColorChangeTest.java index bf727560c9..3fca00eb2c 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerUserColorChangeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerUserColorChangeTest.java @@ -1,19 +1,21 @@ package com.vaadin.tests.components.colorpicker; -import com.vaadin.tests.tb3.MultiBrowserTest; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; +import com.vaadin.tests.tb3.SingleBrowserTest; + import static org.junit.Assert.assertEquals; -public class ColorPickerUserColorChangeTest extends MultiBrowserTest { +public class ColorPickerUserColorChangeTest extends SingleBrowserTest { @Test public void testUserOriginatedTrue() { openTestURL(); + waitUntilLoadingIndicatorNotVisible(); // Open colorPicker - findElement(By.className("v-button-v-colorpicker ")).click(); + findElement(By.className("v-button-v-colorpicker")).click(); sleep(2000); // click somewhere inside the gradient layer findElement(By.className("v-colorpicker-gradient-clicklayer")).click(); diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRangeTest.java index 9718f5c465..c6eac42c5a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRangeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRangeTest.java @@ -1,9 +1,5 @@ package com.vaadin.tests.components.datefield; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.util.ArrayList; import java.util.List; @@ -19,6 +15,10 @@ import com.vaadin.testbench.elements.DateFieldElement; import com.vaadin.testbench.parallel.BrowserUtil; import com.vaadin.tests.tb3.MultiBrowserTest; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + /** * Tests contents and functionality of PopupDateField's popup. * @@ -323,9 +323,7 @@ public class PopupDateFieldExtendedRangeTest extends MultiBrowserTest { // navigate to previous month WebElement popupBody = popup .findElement(By.className("v-datefield-calendarpanel")); - new Actions(driver).keyDown(Keys.SHIFT).perform(); - popupBody.sendKeys(Keys.ARROW_LEFT); - new Actions(driver).keyUp(Keys.SHIFT).perform(); + popupBody.sendKeys(Keys.SHIFT, Keys.ARROW_LEFT); // TODO: remove this once #14406 has been fixed if (BrowserUtil.isIE(getDesiredCapabilities()) @@ -368,9 +366,7 @@ public class PopupDateFieldExtendedRangeTest extends MultiBrowserTest { assertEquals("unexpected day content", "7", days.get(41).getText()); // navigate to previous year - new Actions(driver).keyDown(Keys.SHIFT).perform(); - popupBody.sendKeys(Keys.ARROW_DOWN); - new Actions(driver).keyUp(Keys.SHIFT).perform(); + new Actions(driver).sendKeys(Keys.chord(Keys.SHIFT, Keys.ARROW_DOWN)); // TODO: remove this once #14406 has been fixed popup.findElement(By.className("v-datefield-calendarpanel-prevyear")) diff --git a/uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinatesTest.java b/uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinatesTest.java index 820b07fadb..79ffd1d9cd 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinatesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinatesTest.java @@ -1,18 +1,16 @@ package com.vaadin.tests.components.embedded; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; -import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.elements.EmbeddedElement; import com.vaadin.testbench.elements.LabelElement; import com.vaadin.testbench.parallel.BrowserUtil; import com.vaadin.tests.tb3.MultiBrowserTest; +import static org.junit.Assert.assertEquals; + public class EmbeddedClickListenerRelativeCoordinatesTest extends MultiBrowserTest { @@ -50,8 +48,14 @@ public class EmbeddedClickListenerRelativeCoordinatesTest "Reported X-coordinate from Embedded does not match click location", expectedX, x); - // IE10 and IE11 sometimes click one pixel below the given position - int tolerance = isIE() ? 1 : 0; + // IE10 and IE11 sometimes click one pixel below the given position, + // so does the Chrome(since 75) + int tolerance; + if (isIE() || isChrome()) { + tolerance = 1; + } else { + tolerance = 0; + } assertEquals( "Reported Y-coordinate from Embedded does not match click location", expectedY, y, tolerance); @@ -61,4 +65,8 @@ public class EmbeddedClickListenerRelativeCoordinatesTest return BrowserUtil.isIE(getDesiredCapabilities()); } + private boolean isChrome() { + return BrowserUtil.isChrome(getDesiredCapabilities()); + } + } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/CheckboxAlignmentWithNoHeaderGridTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/CheckboxAlignmentWithNoHeaderGridTest.java index a800d9b0ec..c4ceabc7f7 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/CheckboxAlignmentWithNoHeaderGridTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/CheckboxAlignmentWithNoHeaderGridTest.java @@ -25,7 +25,7 @@ public class CheckboxAlignmentWithNoHeaderGridTest extends SingleBrowserTest { Assert.assertTrue("This should be an empty grid", grid.getRowCount() == 0); - for (int i =0; i<5; i++) { + for (int i = 0; i < 5; i++) { $(ButtonElement.class).first().click(); } sleep(100); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java index 34892da664..3ff3d61809 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java @@ -1,9 +1,5 @@ package com.vaadin.tests.components.grid; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.util.Locale; import java.util.stream.IntStream; import java.util.stream.Stream; @@ -19,12 +15,16 @@ import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement.GridCellElement; import com.vaadin.testbench.elements.GridElement.GridRowElement; -import com.vaadin.testbench.parallel.BrowserUtil; import com.vaadin.testbench.elements.LabelElement; import com.vaadin.testbench.elements.NotificationElement; import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.testbench.parallel.BrowserUtil; import com.vaadin.tests.tb3.MultiBrowserTest; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class GridComponentsTest extends MultiBrowserTest { @Test @@ -228,6 +228,10 @@ public class GridComponentsTest extends MultiBrowserTest { // Navigate to out of viewport TextField in Header new Actions(getDriver()).sendKeys(Keys.chord(Keys.SHIFT, Keys.TAB)) .perform(); + // After Chrome 75, sendkeys issues + if (BrowserUtil.isChrome(getDesiredCapabilities())) { + grid.getHeaderCell(1, 0).findElement(By.id("headerField")).click(); + } assertEquals("Focus should be in TextField in Header", "headerField", getFocusedElement().getAttribute("id")); assertEquals("Grid should've scrolled back to start.", 0, diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEventSentOnColumnVisibilityChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEventSentOnColumnVisibilityChangeTest.java index c315513620..79f6fd7068 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEventSentOnColumnVisibilityChangeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEventSentOnColumnVisibilityChangeTest.java @@ -10,7 +10,8 @@ import com.vaadin.testbench.By; import com.vaadin.testbench.elements.GridElement; import com.vaadin.tests.tb3.SingleBrowserTest; -public class GridEventSentOnColumnVisibilityChangeTest extends SingleBrowserTest { +public class GridEventSentOnColumnVisibilityChangeTest + extends SingleBrowserTest { @Test public void changeVisibilityAssertLog() { @@ -20,7 +21,7 @@ public class GridEventSentOnColumnVisibilityChangeTest extends SingleBrowserTest getSidebarOpenButton(grid).click(); // hide the first column getSidebarPopup().findElements(By.tagName("td")).get(0).click(); - + Assert.assertTrue("Log content should match", "1. UserOriginated: true".equals(getLogRow(0))); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridExtensionCommunicationTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridExtensionCommunicationTest.java index 6cd6597c6b..ef8155b7dd 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridExtensionCommunicationTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridExtensionCommunicationTest.java @@ -1,7 +1,5 @@ package com.vaadin.tests.components.grid; -import static org.junit.Assert.assertEquals; - import org.junit.Test; import com.vaadin.testbench.elements.GridElement; @@ -9,6 +7,8 @@ import com.vaadin.testbench.elements.GridElement.GridCellElement; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.SingleBrowserTest; +import static org.junit.Assert.assertEquals; + @TestCategory("grid") public class GridExtensionCommunicationTest extends SingleBrowserTest { @@ -17,16 +17,10 @@ public class GridExtensionCommunicationTest extends SingleBrowserTest { openTestURL(); GridCellElement cell = $(GridElement.class).first().getCell(0, 1); - cell.click(5, 5); - - int expectedX = cell.getLocation().getX() + 5; - int expectedY = cell.getLocation().getY() + 5; + cell.click(getXOffset(cell, 5), getYOffset(cell, 5)); assertEquals( "1. Click on Person first name 1 last name 1 on column second", getLogRow(1)); - assertEquals("2. MouseEventDetails: left (" + expectedX + ", " - + expectedY + ")", getLogRow(0)); - } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeightTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeightTest.java index 091df96087..0e0e21a424 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeightTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeightTest.java @@ -1,10 +1,5 @@ package com.vaadin.tests.components.grid; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.number.IsCloseTo.closeTo; -import static org.junit.Assert.fail; - import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -19,6 +14,11 @@ import com.vaadin.testbench.elements.RadioButtonGroupElement; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.number.IsCloseTo.closeTo; +import static org.junit.Assert.fail; + /** * Tests that Grid gets correct height based on height mode, and resizes * properly with details row if height is undefined. @@ -98,7 +98,7 @@ public class GridHeightTest extends MultiBrowserTest { detailsRowHeight, "opened" }); } - row.click(getXOffset(row, 5), getYOffset(row, 5)); + row.click(5, 5); waitForElementNotPresent(By.id("lbl1")); int afterHeight = grid.getSize().getHeight(); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicsTest.java index 81f2518afc..3f93855a8f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicsTest.java @@ -131,7 +131,7 @@ public abstract class GridBasicsTest extends MultiBrowserTest { private int getHorizontalOffsetForDragAndDrop(GridCellElement columnHeader, CellSide cellSide) { if (cellSide == CellSide.LEFT) { - return 5; + return -5; } else { int half = columnHeader.getSize().getWidth() / 2; return half + half / 2; diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridSortingTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridSortingTest.java index 42641ab7de..6479b530f1 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridSortingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridSortingTest.java @@ -1,8 +1,5 @@ package com.vaadin.tests.components.grid.basics; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.util.Collections; import java.util.Comparator; import java.util.Date; @@ -15,6 +12,9 @@ import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.testbench.parallel.Browser; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class GridSortingTest extends GridBasicsTest { public static final Comparator<DataObject> BIG_RANDOM = Comparator @@ -46,7 +46,7 @@ public class GridSortingTest extends GridBasicsTest { @Test public void testSortByMultipleColumnsByUser() { getGridElement().getHeaderCell(0, 7).click(); - getGridElement().getHeaderCell(0, 6).click(20, 20, Keys.SHIFT); + getGridElement().getHeaderCell(0, 6).click(0, 0, Keys.SHIFT); int i = 0; for (Integer rowNumber : getTestData() diff --git a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIsAutoOpenScrollingTest.java b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIsAutoOpenScrollingTest.java index 79cc65bed7..28953d4bab 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIsAutoOpenScrollingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIsAutoOpenScrollingTest.java @@ -40,9 +40,8 @@ public class MenuBarIsAutoOpenScrollingTest extends MultiBrowserTest { // here we have to use pause() because LazyCloser in VMenuBar auto // closes submenus popup in 750 ms. - actions.moveToElement(subMenuPopup, subMenuPopup.getSize().width / 2, - 100).clickAndHold().pause(1000).moveByOffset(0, 200).release() - .perform(); + actions.moveToElement(subMenuPopup, 0, 100).clickAndHold().pause(1000) + .moveByOffset(0, 200).release().perform(); // subMenuPopup should still be presented waitUntil(ExpectedConditions diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/ItemClickEventsTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/ItemClickEventsTest.java index dee45d8c5e..0861e662dc 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/ItemClickEventsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/ItemClickEventsTest.java @@ -1,17 +1,17 @@ package com.vaadin.tests.components.table; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import org.junit.Before; import org.junit.Test; import com.vaadin.testbench.TestBenchElement; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.CheckBoxElement; import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.tests.tb3.MultiBrowserTest; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + public class ItemClickEventsTest extends MultiBrowserTest { @Before @@ -21,7 +21,7 @@ public class ItemClickEventsTest extends MultiBrowserTest { private void clickElement(TestBenchElement e) { assertNotNull(e); - e.click(5, 5); + e.click(); } private void doubleClickElement(TestBenchElement e) { @@ -52,6 +52,7 @@ public class ItemClickEventsTest extends MultiBrowserTest { // Select the first item clickElement(table.getRow(0)); assertLog("left click on table/Item 0"); + sleep(100); // Do it again clickElement(table.getRow(0)); @@ -86,6 +87,7 @@ public class ItemClickEventsTest extends MultiBrowserTest { // Check log output assertLog("left click on table/Item 1"); + sleep(500); // Click row 1 again clickElement(table.getRow(1)); diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/ItemClickEventsTestWithShiftOrCtrl.java b/uitest/src/test/java/com/vaadin/tests/components/table/ItemClickEventsTestWithShiftOrCtrl.java index 8ee8ab0b39..3b08df7f99 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/ItemClickEventsTestWithShiftOrCtrl.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/ItemClickEventsTestWithShiftOrCtrl.java @@ -1,8 +1,5 @@ package com.vaadin.tests.components.table; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.util.List; import org.junit.Before; @@ -11,12 +8,15 @@ import org.openqa.selenium.Keys; import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.testbench.TestBenchElement; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.CheckBoxElement; import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.parallel.Browser; import com.vaadin.tests.tb3.MultiBrowserTest; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + public class ItemClickEventsTestWithShiftOrCtrl extends MultiBrowserTest { @Override @@ -32,7 +32,7 @@ public class ItemClickEventsTestWithShiftOrCtrl extends MultiBrowserTest { private void clickElement(TestBenchElement e) { assertNotNull(e); - e.click(5, 5); + e.click(); } private void shiftClickElement(TestBenchElement e) { @@ -132,6 +132,7 @@ public class ItemClickEventsTestWithShiftOrCtrl extends MultiBrowserTest { // Click item 10, verify log output clickElement(table.getCell(9, 0)); assertLog("left click on table/Item 9"); + sleep(100); // Click it again, should not deselect ctrlClickElement(table.getCell(9, 0)); diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/SelectableEditableTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/SelectableEditableTest.java index a161107f25..4b4a836f7a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/SelectableEditableTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/SelectableEditableTest.java @@ -1,18 +1,18 @@ package com.vaadin.tests.components.table; -import static org.junit.Assert.assertTrue; - import org.junit.Test; import com.vaadin.testbench.elements.TableElement; import com.vaadin.tests.tb3.MultiBrowserTest; +import static org.junit.Assert.assertTrue; + public class SelectableEditableTest extends MultiBrowserTest { @Test public void testSelectFromCellWith() throws Exception { openTestURL(); TableElement table = $(TableElement.class).first(); - table.getCell(0, 1).click(70, 12); + table.getCell(0, 1).click(); assertTrue("Element does not have the 'v-selected' css class", hasCssClass(table.getRow(0), "v-selected")); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableItemDescriptionGeneratorUITest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableItemDescriptionGeneratorUITest.java index a04b0a0384..53ae81f734 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableItemDescriptionGeneratorUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableItemDescriptionGeneratorUITest.java @@ -1,7 +1,5 @@ package com.vaadin.tests.components.table; -import static org.junit.Assert.assertEquals; - import java.util.List; import org.junit.Test; @@ -9,10 +7,12 @@ import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.By; import com.vaadin.testbench.TestBenchElement; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.tests.tb3.TooltipTest; +import static org.junit.Assert.assertEquals; + /** * Tests Table tooltips with various settings. * @@ -173,7 +173,7 @@ public class TableItemDescriptionGeneratorUITest extends TooltipTest { new Actions(getDriver()).moveToElement(checkboxes.get(2)).perform(); // move to the corner of the cell - new Actions(getDriver()).moveToElement(cell_3_0, 0, 0).perform(); + moveToCorner(cell_3_0); sleep(1000); // ensure the tooltip is present @@ -194,7 +194,7 @@ public class TableItemDescriptionGeneratorUITest extends TooltipTest { clearTooltip(); // move to the corner of the element, outside of the button - new Actions(getDriver()).moveToElement(cell_1_1, 0, 0).perform(); + moveToCorner(cell_1_1); sleep(1000); // ensure the tooltip is present @@ -215,7 +215,7 @@ public class TableItemDescriptionGeneratorUITest extends TooltipTest { clearTooltip(); // move to the corner of the element, outside of the textfield - new Actions(getDriver()).moveToElement(cell_4_2, 0, 0).perform(); + moveToCorner(cell_4_2); sleep(1000); // ensure the tooltip is present @@ -223,4 +223,10 @@ public class TableItemDescriptionGeneratorUITest extends TooltipTest { clearTooltip(); } + private void moveToCorner(TestBenchElement cell) { + new Actions(getDriver()) + .moveToElement(cell, getXOffset(cell, 0), getYOffset(cell, 0)) + .perform(); + } + } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationModifierKeysTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationModifierKeysTest.java index 243efb114f..353e99cb71 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationModifierKeysTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationModifierKeysTest.java @@ -1,26 +1,27 @@ package com.vaadin.tests.components.ui; -import static org.junit.Assert.assertEquals; - import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.elements.TextAreaElement; -import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.tests.tb3.SingleBrowserTest; + +import static org.junit.Assert.assertEquals; + +public class TextAreaEventPropagationModifierKeysTest + extends SingleBrowserTest { -public class TextAreaEventPropagationModifierKeysTest extends MultiBrowserTest { @Test public void textAreaShiftEnterEventPropagation() throws InterruptedException { openTestURL(); - - WebElement textArea = $(TextAreaElement.class).first(); Actions builder = new Actions(driver); + WebElement textArea = $(TextAreaElement.class).first(); builder.click(textArea); builder.sendKeys(textArea, "first line asdf"); - builder.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER)); + pressKeyCombinations(Keys.SHIFT, Keys.ENTER); builder.sendKeys(textArea, "second line jkl;"); builder.perform(); @@ -37,7 +38,7 @@ public class TextAreaEventPropagationModifierKeysTest extends MultiBrowserTest { Actions builder = new Actions(driver); builder.click(textArea); builder.sendKeys(textArea, "first line asdf"); - builder.sendKeys(Keys.chord(Keys.CONTROL, Keys.ENTER)); + pressKeyCombinations(Keys.CONTROL, Keys.ENTER); builder.sendKeys(textArea, "second line jkl;"); builder.perform(); @@ -49,4 +50,14 @@ public class TextAreaEventPropagationModifierKeysTest extends MultiBrowserTest { protected Class<?> getUIClass() { return TextAreaEventPropagation.class; } + + // That is a workaround after Chrome 75, sendKeys(Keys.shift, Keys.Tab) + // doesn't work + protected void pressKeyCombinations(Keys keyModifier, Keys key) { + + Actions builder = new Actions(driver); + builder.keyDown(keyModifier).perform(); + builder.sendKeys(Keys.chord(key)).perform(); + builder.keyUp(keyModifier).perform(); + } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/uitest/ThemeTest.java b/uitest/src/test/java/com/vaadin/tests/components/uitest/ThemeTest.java index 96108b4064..35a1e7efaf 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/uitest/ThemeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/uitest/ThemeTest.java @@ -2,12 +2,14 @@ package com.vaadin.tests.components.uitest; import java.io.IOException; +import org.junit.Before; import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.By; +import com.vaadin.testbench.Parameters; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.ComboBoxElement; import com.vaadin.testbench.elements.DateFieldElement; @@ -32,6 +34,11 @@ public abstract class ThemeTest extends MultiBrowserTest { protected abstract String getTheme(); + @Before + public void before() { + Parameters.setScreenshotComparisonTolerance(0.1); + } + @Test public void testTheme() throws Exception { openTestURL("theme=" + getTheme()); diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/WindowHeaderButtonKeyboardActionsTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/WindowHeaderButtonKeyboardActionsTest.java index 9d7245bde5..93986f487e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/WindowHeaderButtonKeyboardActionsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/WindowHeaderButtonKeyboardActionsTest.java @@ -1,7 +1,5 @@ package com.vaadin.tests.components.window; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import org.junit.Test; @@ -12,9 +10,11 @@ import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.By; import com.vaadin.testbench.elements.WindowElement; -import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.tests.tb3.SingleBrowserTest; + +import static org.junit.Assert.assertTrue; -public class WindowHeaderButtonKeyboardActionsTest extends MultiBrowserTest { +public class WindowHeaderButtonKeyboardActionsTest extends SingleBrowserTest { private static final String HEADER_CLASS = "v-window-header"; private static final String RESTORE_BOX_CLASS = "v-window-restorebox"; @@ -162,7 +162,8 @@ public class WindowHeaderButtonKeyboardActionsTest extends MultiBrowserTest { pressKeyAndWait(Keys.TAB); assertTrue("Window's close button is the focused element", !closeButton.equals(driver.switchTo().activeElement())); - pressKeyAndWait(Keys.SHIFT, Keys.TAB); + + pressKeyCombinations(Keys.SHIFT, Keys.TAB); assertTrue("Window's close button is not the focused element", closeButton.equals(driver.switchTo().activeElement())); @@ -324,7 +325,7 @@ public class WindowHeaderButtonKeyboardActionsTest extends MultiBrowserTest { pressKeyAndWait(Keys.TAB); assertTrue("Window's maximize button is the focused element", !maximizeButton.equals(driver.switchTo().activeElement())); - pressKeyAndWait(Keys.SHIFT, Keys.TAB); + pressKeyCombinations(Keys.SHIFT, Keys.TAB); assertTrue("Window's maximize button is not the focused element", maximizeButton.equals(driver.switchTo().activeElement())); @@ -401,4 +402,13 @@ public class WindowHeaderButtonKeyboardActionsTest extends MultiBrowserTest { new Actions(driver).sendKeys(key).build().perform(); sleep(1000); } + + // That is a workaround after Chrome 75, sendKeys(Keys.shift, Keys.Tab) + // doesn't work + protected void pressKeyCombinations(Keys keyModifier, Keys key) { + + new Actions(getDriver()).keyDown(keyModifier).perform(); + new Actions(getDriver()).sendKeys(Keys.chord(key)).perform(); + new Actions(getDriver()).keyUp(keyModifier).perform(); + } } diff --git a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java index 103aa469f5..ab8785cc0f 100644 --- a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java +++ b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java @@ -80,7 +80,7 @@ public class BasicCrudGridEditorRowTest extends MultiBrowserTest { // Check values String value = cb.getValue(); - cb.click(5, 5); + cb.click(); assertNotEquals("Checkbox value did not change", value, cb.getValue()); } diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java index 1e054ca404..548ac78e78 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -1210,6 +1210,12 @@ public abstract class AbstractTB3Test extends ParallelTest { final int width = element.getSize().getWidth(); return targetX - ((width + width % 2) / 2); } + + if (BrowserUtil.isChrome(getDesiredCapabilities())) { + // Chrome follow W3C spec and moveToElement is relative to center + final int width = element.getSize().getWidth(); + return targetX - ((width + width % 2) / 2); + } return targetX; } @@ -1231,6 +1237,12 @@ public abstract class AbstractTB3Test extends ParallelTest { final int height = element.getSize().getHeight(); return targetY - ((height + height % 2) / 2); } + + if (BrowserUtil.isChrome(getDesiredCapabilities())) { + // Chrome follow W3C spec and moveToElement is relative to center + final int height = element.getSize().getHeight(); + return targetY - ((height + height % 2) / 2); + } return targetY; } diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/TooltipTest.java b/uitest/src/test/java/com/vaadin/tests/tb3/TooltipTest.java index 07515d7d61..4bb9f4fd5e 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/TooltipTest.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/TooltipTest.java @@ -90,7 +90,8 @@ public abstract class TooltipTest extends MultiBrowserTest { } protected void moveMouseTo(WebElement element, int offsetX, int offsetY) { - new Actions(getDriver()).moveToElement(element, offsetX, offsetY) + new Actions(getDriver()).moveToElement(element, + getXOffset(element, offsetX), getYOffset(element, offsetY)) .perform(); } |