|
2 | 2 |
|
3 | 3 | import org.apache.commons.lang3.StringUtils; |
4 | 4 | import org.openqa.selenium.devtools.Command; |
5 | | -import org.openqa.selenium.devtools.v145.dom.model.RGBA; |
6 | | -import org.openqa.selenium.devtools.v145.emulation.Emulation; |
7 | | -import org.openqa.selenium.devtools.v145.emulation.model.MediaFeature; |
8 | | -import org.openqa.selenium.devtools.v145.emulation.model.ScreenOrientation; |
| 5 | +import org.openqa.selenium.devtools.v147.dom.model.RGBA; |
| 6 | +import org.openqa.selenium.devtools.v147.emulation.Emulation; |
| 7 | +import org.openqa.selenium.devtools.v147.emulation.model.DevicePosture; |
| 8 | +import org.openqa.selenium.devtools.v147.emulation.model.DisplayFeature; |
| 9 | +import org.openqa.selenium.devtools.v147.emulation.model.MediaFeature; |
| 10 | +import org.openqa.selenium.devtools.v147.emulation.model.ScreenOrientation; |
| 11 | +import org.openqa.selenium.devtools.v147.page.model.Viewport; |
9 | 12 |
|
10 | 13 | import java.util.Collections; |
11 | 14 | import java.util.List; |
@@ -130,8 +133,36 @@ public void setDeviceMetricsOverride(Integer width, Integer height, Number devic |
130 | 133 | } |
131 | 134 | screenOrientation = Optional.of(new ScreenOrientation(ScreenOrientation.Type.fromString(screenOrientationType.get()), angle)); |
132 | 135 | } |
133 | | - tools.sendCommand(Emulation.setDeviceMetricsOverride(width, height, deviceScaleFactor, mobile, Optional.empty(), Optional.empty(), Optional.empty(), |
134 | | - Optional.empty(), Optional.empty(), Optional.empty(), screenOrientation, Optional.empty(), Optional.empty(), Optional.empty())); |
| 136 | + setDeviceMetricsOverride(width, height, deviceScaleFactor, mobile, Optional.empty(), |
| 137 | + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), |
| 138 | + Optional.empty(), screenOrientation, Optional.empty(), Optional.empty(), |
| 139 | + Optional.empty(), Optional.empty(), Optional.empty()); |
| 140 | + } |
| 141 | + |
| 142 | + /** |
| 143 | + * Overrides the values of device screen dimensions. |
| 144 | + * |
| 145 | + * @param width Value to override window.screen.width |
| 146 | + * @param height Value to override window.screen.height |
| 147 | + * @param deviceScaleFactor Overriding device scale factor value. 0 disables the override. |
| 148 | + * @param mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text auto-sizing and more. |
| 149 | + * @param scale Scale to apply to resulting view image. Ignored if |dontSetVisibleSize| is set. |
| 150 | + * @param screenWidth Value to override window.screen.width. Ignored if |dontSetVisibleSize| is set. |
| 151 | + * @param screenHeight Value to override window.screen.height. Ignored if |dontSetVisibleSize| is set. |
| 152 | + * @param positionX Overriding view X position on screen in device independent pixels (dip). Ignored if |dontSetVisibleSize| is set. |
| 153 | + * @param positionY Overriding view Y position on screen in device independent pixels (dip). Ignored if |dontSetVisibleSize| is set. |
| 154 | + * @param dontSetVisibleSize Whether to not set visible view size, rely upon explicit setVisibleSize call. Ignored if |scale| is set. |
| 155 | + * @param screenOrientation Orientation of the screen. Ignored if |dontSetVisibleSize| is set. |
| 156 | + * @param viewport If set, the visible area of the overridden device screen, not affecting the reported screen size. Ignored if |dontSetVisibleSize| is set. |
| 157 | + * @param displayFeature Configuration of the display when the system is in unified mode (e.g., foldable devices). |
| 158 | + * @param devicePosture The posture of the device (e.g., foldable devices). |
| 159 | + * @param scrollbarType The type of the scrollbars to render (e.g., mobile vs desktop). Ignored if |dontSetVisibleSize| is set. |
| 160 | + * @param screenOrientationLockEmulation Enables screen orientation lock emulation that intercepts calls to screen.orientation.lock(). |
| 161 | + */ |
| 162 | + public void setDeviceMetricsOverride(Integer width, Integer height, Number deviceScaleFactor, Boolean mobile, Optional<Number> scale, Optional<Integer> screenWidth, Optional<Integer> screenHeight, Optional<Integer> positionX, Optional<Integer> positionY, Optional<Boolean> dontSetVisibleSize, Optional<ScreenOrientation> screenOrientation, Optional<Viewport> viewport, Optional<DisplayFeature> displayFeature, Optional<DevicePosture> devicePosture, Optional<Emulation.SetDeviceMetricsOverrideScrollbarType> scrollbarType, Optional<Boolean> screenOrientationLockEmulation) { |
| 163 | + tools.sendCommand(Emulation.setDeviceMetricsOverride(width, height, deviceScaleFactor, mobile, scale, screenWidth, |
| 164 | + screenHeight, positionX, positionY, dontSetVisibleSize, screenOrientation, viewport, displayFeature, |
| 165 | + devicePosture, scrollbarType, screenOrientationLockEmulation)); |
135 | 166 | } |
136 | 167 |
|
137 | 168 | /** |
|
0 commit comments