22
33import org .apache .commons .lang3 .StringUtils ;
44import org .openqa .selenium .devtools .Command ;
5- import org .openqa .selenium .devtools .v138 .dom .model .RGBA ;
6- import org .openqa .selenium .devtools .v138 .emulation .Emulation ;
7- import org .openqa .selenium .devtools .v138 .emulation .model .MediaFeature ;
8- import org .openqa .selenium .devtools .v138 .emulation .model .ScreenOrientation ;
5+ import org .openqa .selenium .devtools .v140 .dom .model .RGBA ;
6+ import org .openqa .selenium .devtools .v140 .emulation .Emulation ;
7+ import org .openqa .selenium .devtools .v140 .emulation .model .MediaFeature ;
8+ import org .openqa .selenium .devtools .v140 .emulation .model .ScreenOrientation ;
99
1010import java .util .Collections ;
1111import java .util .List ;
@@ -24,6 +24,7 @@ public class EmulationHandling {
2424
2525 /**
2626 * Initializes a new instance of the {@link NetworkHandling} class.
27+ *
2728 * @param tools Instance of {@link DevToolsHandling}.
2829 */
2930 public EmulationHandling (DevToolsHandling tools ) {
@@ -32,17 +33,20 @@ public EmulationHandling(DevToolsHandling tools) {
3233
3334 /**
3435 * Tells whether emulation is supported.
36+ *
3537 * @return true if the emulation is supported, false otherwise.
3638 */
39+ @ Deprecated
3740 public boolean canEmulate () {
3841 return tools .sendCommand (Emulation .canEmulate ());
3942 }
4043
4144 /**
4245 * Overrides the GeoLocation Position or Error. Omitting any of the parameters emulates position unavailable.
43- * @param latitude Latitude of location
46+ *
47+ * @param latitude Latitude of location
4448 * @param longitude Longitude of location
45- * @param accuracy Accuracy of the location
49+ * @param accuracy Accuracy of the location
4650 */
4751 public void setGeolocationOverride (double latitude , double longitude , double accuracy ) {
4852 setGeolocationOverride (Optional .of (latitude ), Optional .of (longitude ), Optional .of (accuracy ), Optional .empty (),
@@ -52,7 +56,8 @@ public void setGeolocationOverride(double latitude, double longitude, double acc
5256 /**
5357 * Overrides the GeoLocation Position. Accuracy of the geoLocation is set to 1 meaning 100% accuracy.
5458 * Omitting any of the parameters emulates position unavailable.
55- * @param latitude Latitude of location
59+ *
60+ * @param latitude Latitude of location
5661 * @param longitude Longitude of location
5762 */
5863 public void setGeolocationOverride (double latitude , double longitude ) {
@@ -61,9 +66,14 @@ public void setGeolocationOverride(double latitude, double longitude) {
6166
6267 /**
6368 * Overrides the GeoLocation Position or Error. Omitting any of the parameters emulates position unavailable.
64- * @param latitude Latitude of location
65- * @param longitude Longitude of location
66- * @param accuracy Accuracy of the location
69+ *
70+ * @param latitude Latitude of location
71+ * @param longitude Longitude of location
72+ * @param altitude Altitude of location
73+ * @param accuracy Accuracy of the location
74+ * @param altitudeAccuracy Altitude accuracy of the location
75+ * @param heading Heading of location
76+ * @param speed Speed of location
6777 */
6878 public void setGeolocationOverride (Optional <Number > latitude , Optional <Number > longitude , Optional <Number > accuracy ,
6979 Optional <Number > altitude , Optional <Number > altitudeAccuracy , Optional <Number > heading ,
@@ -80,6 +90,7 @@ public void clearGeolocationOverride() {
8090
8191 /**
8292 * Overrides the values of device screen dimensions.
93+ *
8394 * @param params Version-specific set of parameters. For example, take a look at {@link Emulation#setDeviceMetricsOverride}
8495 */
8596 public void setDeviceMetricsOverride (Map <String , Object > params ) {
@@ -88,23 +99,25 @@ public void setDeviceMetricsOverride(Map<String, Object> params) {
8899
89100 /**
90101 * Overrides the values of device screen dimensions.
91- * @param width Value to override window.screen.width
92- * @param height Value to override window.screen.height
102+ *
103+ * @param width Value to override window.screen.width
104+ * @param height Value to override window.screen.height
93105 * @param deviceScaleFactor Overriding device scale factor value. 0 disables the override.
94- * @param mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text auto-sizing and more.
106+ * @param mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text auto-sizing and more.
95107 */
96108 public void setDeviceMetricsOverride (Integer width , Integer height , Number deviceScaleFactor , Boolean mobile ) {
97109 setDeviceMetricsOverride (width , height , deviceScaleFactor , mobile , Optional .empty (), Optional .empty ());
98110 }
99111
100112 /**
101113 * Overrides the values of device screen dimensions.
102- * @param width Value to override window.screen.width
103- * @param height Value to override window.screen.height
104- * @param deviceScaleFactor Overriding device scale factor value. 0 disables the override.
105- * @param mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text auto-sizing and more.
106- * @param screenOrientationType Orientation type.
107- * Allowed Values (in any case): portraitPrimary, portraitSecondary, landscapePrimary, landscapeSecondary.
114+ *
115+ * @param width Value to override window.screen.width
116+ * @param height Value to override window.screen.height
117+ * @param deviceScaleFactor Overriding device scale factor value. 0 disables the override.
118+ * @param mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text auto-sizing and more.
119+ * @param screenOrientationType Orientation type.
120+ * Allowed Values (in any case): portraitPrimary, portraitSecondary, landscapePrimary, landscapeSecondary.
108121 * @param screenOrientationAngle Orientation angle. Set only if orientation type was set.
109122 */
110123 public void setDeviceMetricsOverride (Integer width , Integer height , Number deviceScaleFactor , Boolean mobile ,
@@ -130,6 +143,7 @@ public void clearDeviceMetricsOverride() {
130143
131144 /**
132145 * Overrides the values of user agent.
146+ *
133147 * @param params Version-specific set of parameters.
134148 * For example, take a look at {@link Emulation#setUserAgentOverride}
135149 */
@@ -139,6 +153,7 @@ public void setUserAgentOverride(Map<String, Object> params) {
139153
140154 /**
141155 * Overrides the values of user agent.
156+ *
142157 * @param userAgent User agent to use.
143158 */
144159 public void setUserAgentOverride (String userAgent ) {
@@ -147,9 +162,10 @@ public void setUserAgentOverride(String userAgent) {
147162
148163 /**
149164 * Overrides the values of user agent.
150- * @param userAgent User agent to use.
165+ *
166+ * @param userAgent User agent to use.
151167 * @param acceptLanguage Browser language to emulate.
152- * @param platform The platform navigator.platform should return.
168+ * @param platform The platform navigator.platform should return.
153169 */
154170 public void setUserAgentOverride (String userAgent , Optional <String > acceptLanguage , Optional <String > platform ) {
155171 tools .sendCommand (Emulation .setUserAgentOverride (userAgent , acceptLanguage , platform , Optional .empty ()));
@@ -164,6 +180,7 @@ public void setScriptExecutionDisabled() {
164180
165181 /**
166182 * Switches script execution in the page.
183+ *
167184 * @param value Whether script execution should be disabled in the page.
168185 */
169186 public void setScriptExecutionDisabled (boolean value ) {
@@ -179,6 +196,7 @@ public void setTouchEmulationEnabled() {
179196
180197 /**
181198 * Enables touch on platforms which do not support them.
199+ *
182200 * @param enabled Whether the touch event emulation should be enabled.
183201 */
184202 public void setTouchEmulationEnabled (boolean enabled ) {
@@ -187,7 +205,8 @@ public void setTouchEmulationEnabled(boolean enabled) {
187205
188206 /**
189207 * Enables touch on platforms which do not support them.
190- * @param enabled Whether the touch event emulation should be enabled.
208+ *
209+ * @param enabled Whether the touch event emulation should be enabled.
191210 * @param maxTouchPoints Maximum touch points supported. Defaults to one.
192211 */
193212 public void setTouchEmulationEnabled (boolean enabled , Optional <Integer > maxTouchPoints ) {
@@ -196,6 +215,7 @@ public void setTouchEmulationEnabled(boolean enabled, Optional<Integer> maxTouch
196215
197216 /**
198217 * Emulates the given media type or media feature for CSS media queries.
218+ *
199219 * @param params Version-specific set of parameters. For example, take a look at {@link Emulation#setEmulatedMedia}
200220 */
201221 public void setEmulatedMedia (Map <String , Object > params ) {
@@ -204,8 +224,9 @@ public void setEmulatedMedia(Map<String, Object> params) {
204224
205225 /**
206226 * Emulates the given media type or media feature for CSS media queries.
207- * @param media Media type to emulate. Empty string disables the override.
208- * Possible values: braille, embossed, handheld, print, projection, screen, speech, tty, tv.
227+ *
228+ * @param media Media type to emulate. Empty string disables the override.
229+ * Possible values: braille, embossed, handheld, print, projection, screen, speech, tty, tv.
209230 * @param mediaFeatures Media features to emulate.
210231 */
211232 public void setEmulatedMedia (String media , Map <String , String > mediaFeatures ) {
@@ -214,8 +235,9 @@ public void setEmulatedMedia(String media, Map<String, String> mediaFeatures) {
214235
215236 /**
216237 * Emulates the given media type or media feature for CSS media queries.
217- * @param media Media type to emulate. Empty string disables the override.
218- * Possible values: braille, embossed, handheld, print, projection, screen, speech, tty, tv.
238+ *
239+ * @param media Media type to emulate. Empty string disables the override.
240+ * Possible values: braille, embossed, handheld, print, projection, screen, speech, tty, tv.
219241 * @param mediaFeatures Media features to emulate.
220242 */
221243 public void setEmulatedMedia (Optional <String > media , Optional <Map <String , String >> mediaFeatures ) {
@@ -233,19 +255,21 @@ public void disableEmulatedMediaOverride() {
233255
234256 /**
235257 * Sets an override of the default background color of the frame. This override is used if the content does not specify one.
236- * @param red The red component, in the [0-255] range.
258+ *
259+ * @param red The red component, in the [0-255] range.
237260 * @param green The green component, in the [0-255] range.
238- * @param blue The blue component, in the [0-255] range.
261+ * @param blue The blue component, in the [0-255] range.
239262 */
240263 public void setDefaultBackgroundColorOverride (int red , int green , int blue ) {
241264 setDefaultBackgroundColorOverride (red , green , blue , Optional .empty ());
242265 }
243266
244267 /**
245268 * Sets an override of the default background color of the frame. This override is used if the content does not specify one.
246- * @param red The red component, in the [0-255] range.
269+ *
270+ * @param red The red component, in the [0-255] range.
247271 * @param green The green component, in the [0-255] range.
248- * @param blue The blue component, in the [0-255] range.
272+ * @param blue The blue component, in the [0-255] range.
249273 * @param alpha The alpha component, in the [0-1] range (default: 1).
250274 */
251275 public void setDefaultBackgroundColorOverride (int red , int green , int blue , Optional <Number > alpha ) {
0 commit comments