From feca86235509a0a4a0118e47c0d31f1ee827880b Mon Sep 17 00:00:00 2001 From: Aleksey Meleshko Date: Fri, 17 Apr 2026 14:05:44 +0200 Subject: [PATCH 1/2] Update to Selenium 4.43.0 +semver:feature Update plugins and dependencies versions. Update DevTools references. Add new signature of method to setDeviceMetricsOverride with more parameters --- pom.xml | 2 +- .../browser/devtools/DevToolsHandling.java | 4 +- .../browser/devtools/EmulationHandling.java | 43 ++++++++++++++++--- .../browser/devtools/JavaScriptHandling.java | 6 +-- .../browser/devtools/NetworkHandling.java | 6 +-- .../devtools/DeviceEmulationTest.java | 4 +- .../devtools/NetworkSpeedEmulationTest.java | 4 +- .../devtools/OverrideUserAgentTest.java | 2 +- 8 files changed, 51 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index 65843de..d00a62b 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ com.github.aquality-automation aquality-selenium-core - 4.13.0 + 4.14.0 org.apache.commons diff --git a/src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java b/src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java index f2cface..236685d 100644 --- a/src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java +++ b/src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java @@ -9,8 +9,8 @@ import org.openqa.selenium.devtools.DevTools; import org.openqa.selenium.devtools.Event; import org.openqa.selenium.devtools.HasDevTools; -import org.openqa.selenium.devtools.v145.performance.Performance; -import org.openqa.selenium.devtools.v145.performance.model.Metric; +import org.openqa.selenium.devtools.v147.performance.Performance; +import org.openqa.selenium.devtools.v147.performance.model.Metric; import java.util.List; import java.util.Map; diff --git a/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java b/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java index e470827..3f84a6d 100644 --- a/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java +++ b/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java @@ -2,10 +2,13 @@ import org.apache.commons.lang3.StringUtils; import org.openqa.selenium.devtools.Command; -import org.openqa.selenium.devtools.v145.dom.model.RGBA; -import org.openqa.selenium.devtools.v145.emulation.Emulation; -import org.openqa.selenium.devtools.v145.emulation.model.MediaFeature; -import org.openqa.selenium.devtools.v145.emulation.model.ScreenOrientation; +import org.openqa.selenium.devtools.v147.dom.model.RGBA; +import org.openqa.selenium.devtools.v147.emulation.Emulation; +import org.openqa.selenium.devtools.v147.emulation.model.DevicePosture; +import org.openqa.selenium.devtools.v147.emulation.model.DisplayFeature; +import org.openqa.selenium.devtools.v147.emulation.model.MediaFeature; +import org.openqa.selenium.devtools.v147.emulation.model.ScreenOrientation; +import org.openqa.selenium.devtools.v147.page.model.Viewport; import java.util.Collections; import java.util.List; @@ -130,8 +133,36 @@ public void setDeviceMetricsOverride(Integer width, Integer height, Number devic } screenOrientation = Optional.of(new ScreenOrientation(ScreenOrientation.Type.fromString(screenOrientationType.get()), angle)); } - tools.sendCommand(Emulation.setDeviceMetricsOverride(width, height, deviceScaleFactor, mobile, Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), screenOrientation, Optional.empty(), Optional.empty(), Optional.empty())); + setDeviceMetricsOverride(width, height, deviceScaleFactor, mobile, Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), screenOrientation, Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty()); + } + + /** + * Overrides the values of device screen dimensions. + * + * @param width Value to override window.screen.width + * @param height Value to override window.screen.height + * @param deviceScaleFactor Overriding device scale factor value. 0 disables the override. + * @param mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text auto-sizing and more. + * @param scale Scale to apply to resulting view image. Ignored in |dontSetVisibleSize| is not set. + * @param screenWidth Value to override window.screen.width. Ignored in |dontSetVisibleSize| is not set. + * @param screenHeight Value to override window.screen.height. Ignored in |dontSetVisibleSize| is not set. + * @param positionX Overriding view X position on screen in device independent pixels (dip). Ignored in |dontSetVisibleSize| is not set. + * @param positionY Overriding view Y position on screen in device independent pixels (dip). Ignored in |dontSetVisibleSize| is not set. + * @param dontSetVisibleSize Whether to not set visible view size, rely upon explicit setVisibleSize call. Ignored in |scale| is not set. + * @param screenOrientation Orientation of the screen. This is ignored in |dontSetVisibleSize| is not set. + * @param viewport If set, the visible area of the overridden device screen, not affecting the reported screen size. Ignored in |dontSetVisibleSize| is not set. + * @param displayFeature Configuration of the display when the system is in unified mode (e.g. foldable devices). + * @param devicePosture The posture of the device (e.g. foldable devices). + * @param scrollbarType The type of the scrollbars to render (e.g. mobile vs desktop). Ignored in |dontSetVisibleSize| is not set. + * @param screenOrientationLockEmulation Whether to emulate a focused form control that would cause the virtual keyboard to pop up. Ignored in |dontSetVisibleSize| is not set. + */ + public void setDeviceMetricsOverride(Integer width, Integer height, Number deviceScaleFactor, Boolean mobile, Optional scale, Optional screenWidth, Optional screenHeight, Optional positionX, Optional positionY, Optional dontSetVisibleSize, Optional screenOrientation, Optional viewport, Optional displayFeature, Optional devicePosture, Optional scrollbarType, Optional screenOrientationLockEmulation) { + tools.sendCommand(Emulation.setDeviceMetricsOverride(width, height, deviceScaleFactor, mobile, scale, screenWidth, + screenHeight, positionX, positionY, dontSetVisibleSize, screenOrientation, viewport, displayFeature, + devicePosture, scrollbarType, screenOrientationLockEmulation)); } /** diff --git a/src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java b/src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java index 5c6e76b..da72139 100644 --- a/src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java +++ b/src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java @@ -12,9 +12,9 @@ import org.openqa.selenium.devtools.idealized.Javascript; import org.openqa.selenium.devtools.idealized.ScriptId; import org.openqa.selenium.devtools.idealized.target.model.SessionID; -import org.openqa.selenium.devtools.v145.page.Page; -import org.openqa.selenium.devtools.v145.page.model.ScriptIdentifier; -import org.openqa.selenium.devtools.v145.runtime.Runtime; +import org.openqa.selenium.devtools.v147.page.Page; +import org.openqa.selenium.devtools.v147.page.model.ScriptIdentifier; +import org.openqa.selenium.devtools.v147.runtime.Runtime; import org.openqa.selenium.logging.EventType; import org.openqa.selenium.logging.HasLogEvents; import org.openqa.selenium.remote.Augmenter; diff --git a/src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java b/src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java index 5b14155..6db0beb 100644 --- a/src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java +++ b/src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java @@ -8,7 +8,7 @@ import org.openqa.selenium.UsernameAndPassword; import org.openqa.selenium.devtools.NetworkInterceptor; import org.openqa.selenium.devtools.idealized.Network; -import org.openqa.selenium.devtools.v145.network.model.*; +import org.openqa.selenium.devtools.v147.network.model.*; import org.openqa.selenium.remote.http.*; import java.net.URI; @@ -22,11 +22,11 @@ import static aquality.selenium.browser.AqualityServices.getBrowser; import static aquality.selenium.logging.LocalizedLoggerUtility.logByLevel; -import static org.openqa.selenium.devtools.v145.network.Network.*; +import static org.openqa.selenium.devtools.v147.network.Network.*; /** * DevTools commands for version-independent network interception. - * For more information, see {@link org.openqa.selenium.devtools.v145.network.Network} and {@link Network}. + * For more information, see {@link org.openqa.selenium.devtools.v147.network.Network} and {@link Network}. */ public class NetworkHandling { public static final String LOC_NETWORK_INTERCEPTOR_START = "loc.browser.network.interceptor.start"; diff --git a/src/test/java/tests/usecases/devtools/DeviceEmulationTest.java b/src/test/java/tests/usecases/devtools/DeviceEmulationTest.java index 669e2e1..3c12369 100644 --- a/src/test/java/tests/usecases/devtools/DeviceEmulationTest.java +++ b/src/test/java/tests/usecases/devtools/DeviceEmulationTest.java @@ -3,8 +3,8 @@ import aquality.selenium.browser.AqualityServices; import aquality.selenium.browser.devtools.EmulationHandling; import com.google.common.collect.ImmutableMap; -import org.openqa.selenium.devtools.v144.emulation.Emulation; -import org.openqa.selenium.devtools.v144.emulation.model.DisplayFeature; +import org.openqa.selenium.devtools.v146.emulation.Emulation; +import org.openqa.selenium.devtools.v146.emulation.model.DisplayFeature; import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; diff --git a/src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java b/src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java index 852fe3b..673542a 100644 --- a/src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java +++ b/src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java @@ -3,8 +3,8 @@ import aquality.selenium.browser.AqualityServices; import aquality.selenium.browser.devtools.NetworkHandling; import org.openqa.selenium.TimeoutException; -import org.openqa.selenium.devtools.v145.network.model.ConnectionType; -import org.openqa.selenium.devtools.v145.network.model.NetworkConditions; +import org.openqa.selenium.devtools.v147.network.model.ConnectionType; +import org.openqa.selenium.devtools.v147.network.model.NetworkConditions; import org.testng.Assert; import org.testng.annotations.Test; import tests.BaseTest; diff --git a/src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java b/src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java index 3de9cbd..e9fe5dd 100644 --- a/src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java +++ b/src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java @@ -8,7 +8,7 @@ import manytools.BrowserLanguageForm; import manytools.UserAgentForm; import org.openqa.selenium.devtools.idealized.Network; -import org.openqa.selenium.devtools.v144.emulation.Emulation; +import org.openqa.selenium.devtools.v146.emulation.Emulation; import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; From be5638cb3c743041331d664aa409435de7e4fcc2 Mon Sep 17 00:00:00 2001 From: Aleksey Meleshko Date: Fri, 17 Apr 2026 14:24:22 +0200 Subject: [PATCH 2/2] fix javadocs issue --- .../browser/devtools/EmulationHandling.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java b/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java index 3f84a6d..c4e484a 100644 --- a/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java +++ b/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java @@ -146,18 +146,18 @@ public void setDeviceMetricsOverride(Integer width, Integer height, Number devic * @param height Value to override window.screen.height * @param deviceScaleFactor Overriding device scale factor value. 0 disables the override. * @param mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text auto-sizing and more. - * @param scale Scale to apply to resulting view image. Ignored in |dontSetVisibleSize| is not set. - * @param screenWidth Value to override window.screen.width. Ignored in |dontSetVisibleSize| is not set. - * @param screenHeight Value to override window.screen.height. Ignored in |dontSetVisibleSize| is not set. - * @param positionX Overriding view X position on screen in device independent pixels (dip). Ignored in |dontSetVisibleSize| is not set. - * @param positionY Overriding view Y position on screen in device independent pixels (dip). Ignored in |dontSetVisibleSize| is not set. - * @param dontSetVisibleSize Whether to not set visible view size, rely upon explicit setVisibleSize call. Ignored in |scale| is not set. - * @param screenOrientation Orientation of the screen. This is ignored in |dontSetVisibleSize| is not set. - * @param viewport If set, the visible area of the overridden device screen, not affecting the reported screen size. Ignored in |dontSetVisibleSize| is not set. - * @param displayFeature Configuration of the display when the system is in unified mode (e.g. foldable devices). - * @param devicePosture The posture of the device (e.g. foldable devices). - * @param scrollbarType The type of the scrollbars to render (e.g. mobile vs desktop). Ignored in |dontSetVisibleSize| is not set. - * @param screenOrientationLockEmulation Whether to emulate a focused form control that would cause the virtual keyboard to pop up. Ignored in |dontSetVisibleSize| is not set. + * @param scale Scale to apply to resulting view image. Ignored if |dontSetVisibleSize| is set. + * @param screenWidth Value to override window.screen.width. Ignored if |dontSetVisibleSize| is set. + * @param screenHeight Value to override window.screen.height. Ignored if |dontSetVisibleSize| is set. + * @param positionX Overriding view X position on screen in device independent pixels (dip). Ignored if |dontSetVisibleSize| is set. + * @param positionY Overriding view Y position on screen in device independent pixels (dip). Ignored if |dontSetVisibleSize| is set. + * @param dontSetVisibleSize Whether to not set visible view size, rely upon explicit setVisibleSize call. Ignored if |scale| is set. + * @param screenOrientation Orientation of the screen. Ignored if |dontSetVisibleSize| is set. + * @param viewport If set, the visible area of the overridden device screen, not affecting the reported screen size. Ignored if |dontSetVisibleSize| is set. + * @param displayFeature Configuration of the display when the system is in unified mode (e.g., foldable devices). + * @param devicePosture The posture of the device (e.g., foldable devices). + * @param scrollbarType The type of the scrollbars to render (e.g., mobile vs desktop). Ignored if |dontSetVisibleSize| is set. + * @param screenOrientationLockEmulation Enables screen orientation lock emulation that intercepts calls to screen.orientation.lock(). */ public void setDeviceMetricsOverride(Integer width, Integer height, Number deviceScaleFactor, Boolean mobile, Optional scale, Optional screenWidth, Optional screenHeight, Optional positionX, Optional positionY, Optional dontSetVisibleSize, Optional screenOrientation, Optional viewport, Optional displayFeature, Optional devicePosture, Optional scrollbarType, Optional screenOrientationLockEmulation) { tools.sendCommand(Emulation.setDeviceMetricsOverride(width, height, deviceScaleFactor, mobile, scale, screenWidth,