From 280084a905635412c26f0fab689188cb9d001fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20I=C3=9Fbr=C3=BCcker?= Date: Wed, 27 Nov 2024 08:06:43 +0100 Subject: [PATCH] test: make integration tests work with new headless mode (#6869) --- .../dataview/AbstractItemCountComboBoxIT.java | 2 +- .../com/vaadin/tests/AbstractComponentIT.java | 25 +++---------------- .../spreadsheet/test/ContextMenuIT.java | 5 ++-- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/vaadin-combo-box-flow-parent/vaadin-combo-box-flow-integration-tests/src/test/java/com/vaadin/flow/component/combobox/test/dataview/AbstractItemCountComboBoxIT.java b/vaadin-combo-box-flow-parent/vaadin-combo-box-flow-integration-tests/src/test/java/com/vaadin/flow/component/combobox/test/dataview/AbstractItemCountComboBoxIT.java index 2df2fa9dbf8..510013ce840 100644 --- a/vaadin-combo-box-flow-parent/vaadin-combo-box-flow-integration-tests/src/test/java/com/vaadin/flow/component/combobox/test/dataview/AbstractItemCountComboBoxIT.java +++ b/vaadin-combo-box-flow-parent/vaadin-combo-box-flow-integration-tests/src/test/java/com/vaadin/flow/component/combobox/test/dataview/AbstractItemCountComboBoxIT.java @@ -32,7 +32,7 @@ public abstract class AbstractItemCountComboBoxIT extends AbstractComboBoxIT { // changing the dimension might get combo box change what it fetches and // how many items it shows, so changing this is a bad idea ... - private static final Dimension TARGET_SIZE = new Dimension(1000, 900); + private static final Dimension TARGET_SIZE = new Dimension(1000, 1100); protected ComboBoxElement comboBoxElement; protected int countIncreasePageCount = 4; protected int pageSize = new ComboBox().getPageSize(); diff --git a/vaadin-flow-components-shared-parent/vaadin-flow-components-test-util/src/main/java/com/vaadin/tests/AbstractComponentIT.java b/vaadin-flow-components-shared-parent/vaadin-flow-components-test-util/src/main/java/com/vaadin/tests/AbstractComponentIT.java index 7720ea8ceae..11bdae98258 100644 --- a/vaadin-flow-components-shared-parent/vaadin-flow-components-test-util/src/main/java/com/vaadin/tests/AbstractComponentIT.java +++ b/vaadin-flow-components-shared-parent/vaadin-flow-components-test-util/src/main/java/com/vaadin/tests/AbstractComponentIT.java @@ -15,11 +15,6 @@ */ package com.vaadin.tests; -import java.util.List; - -import org.openqa.selenium.chrome.ChromeOptions; -import org.openqa.selenium.remote.DesiredCapabilities; - public abstract class AbstractComponentIT extends com.vaadin.flow.testutil.AbstractComponentIT { @@ -28,22 +23,10 @@ protected int getDeploymentPort() { } @Override - protected List customizeCapabilities( - List capabilities) { - // This method is overridden to force the legacy Chrome headless mode - // for the time being. The new `--headless=new` mode has an issue - // that doesn't allow tests to adjust the browser window size with - // `getDriver().manage().window().setSize(...)`, see more: - // https://github.com/SeleniumHQ/selenium/issues/11706 - ChromeOptions chromeOptions = new ChromeOptions(); - chromeOptions.addArguments("--headless", "--disable-gpu"); + public void setup() throws Exception { + super.setup(); - capabilities.stream() - .filter(cap -> "chrome".equalsIgnoreCase(cap.getBrowserName())) - .forEach(cap -> cap.setCapability(ChromeOptions.CAPABILITY, - chromeOptions)); - - return capabilities; + // Set a default window size + testBench().resizeViewPortTo(1024, 800); } - } diff --git a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow-integration-tests/src/test/java/com/vaadin/flow/component/spreadsheet/test/ContextMenuIT.java b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow-integration-tests/src/test/java/com/vaadin/flow/component/spreadsheet/test/ContextMenuIT.java index 3e494a93479..5f8cc941183 100644 --- a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow-integration-tests/src/test/java/com/vaadin/flow/component/spreadsheet/test/ContextMenuIT.java +++ b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow-integration-tests/src/test/java/com/vaadin/flow/component/spreadsheet/test/ContextMenuIT.java @@ -34,8 +34,9 @@ public void documentScroll_overlayPosition() { // Make sure to use a small enough viewport so that the document needs // to be scrolled to see the cell getDriver().manage().window().setSize(WINDOW_SIZE_SMALL); - // Scroll the document horizontally - executeScript("document.documentElement.scrollLeft = 100"); + // Scroll the document so the cell is visible + executeScript( + "document.documentElement.scrollLeft = 100;document.documentElement.scrollTop = 200;"); var cell = getSpreadsheet().getCellAt("B2"); // Open context menu for the cell