Skip to content

Commit a06c342

Browse files
authored
Update to Selenium 4.36.0 +semver:feature (#154)
Update DevTools references to use V140 Fix issues in javadocs Deprecate canEmulate() method
1 parent b2727b9 commit a06c342

File tree

14 files changed

+169
-112
lines changed

14 files changed

+169
-112
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<dependency>
7171
<groupId>com.github.aquality-automation</groupId>
7272
<artifactId>aquality-selenium-core</artifactId>
73-
<version>4.8.0</version>
73+
<version>4.9.0</version>
7474
</dependency>
7575
<dependency>
7676
<groupId>org.apache.commons</groupId>

src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.openqa.selenium.devtools.DevTools;
1010
import org.openqa.selenium.devtools.Event;
1111
import org.openqa.selenium.devtools.HasDevTools;
12-
import org.openqa.selenium.devtools.v138.performance.Performance;
13-
import org.openqa.selenium.devtools.v138.performance.model.Metric;
12+
import org.openqa.selenium.devtools.v140.performance.Performance;
13+
import org.openqa.selenium.devtools.v140.performance.model.Metric;
1414

1515
import java.util.List;
1616
import java.util.Map;

src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import org.apache.commons.lang3.StringUtils;
44
import 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

1010
import java.util.Collections;
1111
import 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) {

src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
import org.openqa.selenium.devtools.idealized.Javascript;
1313
import org.openqa.selenium.devtools.idealized.ScriptId;
1414
import org.openqa.selenium.devtools.idealized.target.model.SessionID;
15-
import org.openqa.selenium.devtools.v138.page.Page;
16-
import org.openqa.selenium.devtools.v138.page.model.ScriptIdentifier;
17-
import org.openqa.selenium.devtools.v138.runtime.Runtime;
15+
import org.openqa.selenium.devtools.v140.page.Page;
16+
import org.openqa.selenium.devtools.v140.page.model.ScriptIdentifier;
17+
import org.openqa.selenium.devtools.v140.runtime.Runtime;
1818
import org.openqa.selenium.logging.EventType;
1919
import org.openqa.selenium.logging.HasLogEvents;
2020
import org.openqa.selenium.remote.Augmenter;

src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.openqa.selenium.UsernameAndPassword;
99
import org.openqa.selenium.devtools.NetworkInterceptor;
1010
import org.openqa.selenium.devtools.idealized.Network;
11-
import org.openqa.selenium.devtools.v138.network.model.*;
11+
import org.openqa.selenium.devtools.v140.network.model.*;
1212
import org.openqa.selenium.remote.http.*;
1313

1414
import java.net.URI;
@@ -22,11 +22,11 @@
2222

2323
import static aquality.selenium.browser.AqualityServices.getBrowser;
2424
import static aquality.selenium.logging.LocalizedLoggerUtility.logByLevel;
25-
import static org.openqa.selenium.devtools.v138.network.Network.*;
25+
import static org.openqa.selenium.devtools.v140.network.Network.*;
2626

2727
/**
2828
* DevTools commands for version-independent network interception.
29-
* For more information, see {@link org.openqa.selenium.devtools.v138.network.Network} and {@link Network}.
29+
* For more information, see {@link org.openqa.selenium.devtools.v140.network.Network} and {@link Network}.
3030
*/
3131
public class NetworkHandling {
3232
public static final String LOC_NETWORK_INTERCEPTOR_START = "loc.browser.network.interceptor.start";
@@ -80,6 +80,7 @@ public void setUserAgent(Network.UserAgent userAgent) {
8080

8181
/**
8282
* Add basic authentication handler.
83+
* @param whenThisMatches URI matcher.
8384
* @param useTheseCredentials parameters, such as URI matcher and credentials.
8485
*/
8586
public void addAuthHandler(Predicate<URI> whenThisMatches, Supplier<Credentials> useTheseCredentials) {
@@ -199,7 +200,7 @@ private Consumer<ResponseReceived> getResponseLogger(HttpExchangeLoggingOptions
199200
formatHeaders(response.getHeaders()));
200201
}
201202
if (loggingOptions.getResponseBody().isEnabled()) {
202-
String responseBody = tools.sendCommand(org.openqa.selenium.devtools.v138.network.Network.getResponseBody(requestId)).getBody();
203+
String responseBody = tools.sendCommand(org.openqa.selenium.devtools.v140.network.Network.getResponseBody(requestId)).getBody();
203204
if (StringUtils.isNotEmpty(responseBody)) {
204205
logByLevel(loggingOptions.getResponseBody().getLogLevel(),
205206
"loc.browser.network.event.responsereceived.log.body",

src/main/java/aquality/selenium/elements/actions/JsActions.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public SearchContext expandShadowRoot() {
3535

3636
/**
3737
* Setting attribute value.
38-
* @param name Attribute name
38+
*
39+
* @param name Attribute name
3940
* @param value Value to set
4041
*/
4142
public void setAttribute(String name, String value) {
@@ -69,6 +70,8 @@ public void highlightElement() {
6970

7071
/**
7172
* Highlights the element.
73+
*
74+
* @param highlightState Highlight state
7275
*/
7376
public void highlightElement(HighlightState highlightState) {
7477
if ((AqualityServices.getBrowserProfile().isElementHighlightEnabled() && !highlightState.equals(HighlightState.NOT_HIGHLIGHT))
@@ -186,7 +189,9 @@ private Object[] resolveArguments(Object... args) {
186189

187190
/**
188191
* Executes pinned JavaScript against the element and gets result value.
192+
*
189193
* @param pinnedScript Instance of script pinned with {@link Browser#javaScriptEngine()}
194+
* @param args Script arguments.
190195
* @return Script execution result.
191196
*/
192197
public Object executeScript(ScriptKey pinnedScript, Object... args) {
@@ -209,7 +214,8 @@ protected Object executeScript(JavaScript javaScript, Object... args) {
209214
/**
210215
* The implementation of a method for logging of Javascript actions
211216
*
212-
* @param key key in localization resource of message to display in the log.
217+
* @param key key in localization resource of message to display in the log.
218+
* @param args arguments for message formatting.
213219
*/
214220
protected void logElementAction(String key, Object... args) {
215221
AqualityServices.getLocalizedLogger().infoElementAction(type, name, key, args);

0 commit comments

Comments
 (0)