Skip to content

Commit 10fc6d1

Browse files
authored
Update to Selenium 4.46.0 (#164)
* Update to Selenium 4.46.0 +semver:feature Update plugins and dependencies versions. Update DevTools references to v150. Add new signature of method to emulateConditionsByRule with more parameters * Stabilize ManyTools site navigation and waits
1 parent e1a93c4 commit 10fc6d1

10 files changed

Lines changed: 54 additions & 32 deletions

File tree

pom.xml

Lines changed: 5 additions & 5 deletions
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.15.0</version>
73+
<version>4.16.0</version>
7474
</dependency>
7575
<dependency>
7676
<groupId>org.apache.commons</groupId>
@@ -80,7 +80,7 @@
8080
<dependency>
8181
<groupId>com.fasterxml.jackson.core</groupId>
8282
<artifactId>jackson-databind</artifactId>
83-
<version>2.21.3</version>
83+
<version>2.22.1</version>
8484
</dependency>
8585
<dependency>
8686
<groupId>org.slf4j</groupId>
@@ -116,7 +116,7 @@
116116
<plugin>
117117
<groupId>org.jacoco</groupId>
118118
<artifactId>jacoco-maven-plugin</artifactId>
119-
<version>0.8.14</version>
119+
<version>0.8.15</version>
120120
<executions>
121121
<execution>
122122
<id>pre-unit-test</id>
@@ -144,7 +144,7 @@
144144
<plugin>
145145
<groupId>org.apache.maven.plugins</groupId>
146146
<artifactId>maven-surefire-plugin</artifactId>
147-
<version>3.5.5</version>
147+
<version>3.5.6</version>
148148
<configuration>
149149
<argLine>${surefireArgLine} -Dfile.encoding=UTF-8</argLine>
150150
<reuseForks>false</reuseForks>
@@ -223,7 +223,7 @@
223223
<plugin>
224224
<groupId>org.sonatype.central</groupId>
225225
<artifactId>central-publishing-maven-plugin</artifactId>
226-
<version>0.10.0</version>
226+
<version>0.11.0</version>
227227
<extensions>true</extensions>
228228
<configuration>
229229
<publishingServerId>central</publishingServerId>

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.v148.performance.Performance;
13-
import org.openqa.selenium.devtools.v148.performance.model.Metric;
12+
import org.openqa.selenium.devtools.v150.performance.Performance;
13+
import org.openqa.selenium.devtools.v150.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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
import org.apache.commons.lang3.StringUtils;
44
import org.openqa.selenium.devtools.Command;
5-
import org.openqa.selenium.devtools.v148.dom.model.RGBA;
6-
import org.openqa.selenium.devtools.v148.emulation.Emulation;
7-
import org.openqa.selenium.devtools.v148.emulation.model.DevicePosture;
8-
import org.openqa.selenium.devtools.v148.emulation.model.DisplayFeature;
9-
import org.openqa.selenium.devtools.v148.emulation.model.MediaFeature;
10-
import org.openqa.selenium.devtools.v148.emulation.model.ScreenOrientation;
11-
import org.openqa.selenium.devtools.v148.page.model.Viewport;
5+
import org.openqa.selenium.devtools.v150.dom.model.RGBA;
6+
import org.openqa.selenium.devtools.v150.emulation.Emulation;
7+
import org.openqa.selenium.devtools.v150.emulation.model.DevicePosture;
8+
import org.openqa.selenium.devtools.v150.emulation.model.DisplayFeature;
9+
import org.openqa.selenium.devtools.v150.emulation.model.MediaFeature;
10+
import org.openqa.selenium.devtools.v150.emulation.model.ScreenOrientation;
11+
import org.openqa.selenium.devtools.v150.page.model.Viewport;
1212

1313
import java.util.Collections;
1414
import java.util.List;

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.v148.page.Page;
16-
import org.openqa.selenium.devtools.v148.page.model.ScriptIdentifier;
17-
import org.openqa.selenium.devtools.v148.runtime.Runtime;
15+
import org.openqa.selenium.devtools.v150.page.Page;
16+
import org.openqa.selenium.devtools.v150.page.model.ScriptIdentifier;
17+
import org.openqa.selenium.devtools.v150.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: 18 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.v148.network.model.*;
11+
import org.openqa.selenium.devtools.v150.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.v148.network.Network.*;
25+
import static org.openqa.selenium.devtools.v150.network.Network.*;
2626

2727
/**
2828
* DevTools commands for version-independent network interception.
29-
* For more information, see {@link org.openqa.selenium.devtools.v148.network.Network} and {@link Network}.
29+
* For more information, see {@link org.openqa.selenium.devtools.v150.network.Network} and {@link Network}.
3030
*/
3131
public class NetworkHandling {
3232
public static final String LOC_NETWORK_INTERCEPTOR_START = "loc.browser.network.interceptor.start";
@@ -358,7 +358,21 @@ public void emulateConditions(Boolean offline, Number latency, Number downloadTh
358358
*/
359359
public void emulateConditionsByRule(Boolean offline, List<NetworkConditions> matchedNetworkConditions) {
360360
tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()));
361-
tools.sendCommand(emulateNetworkConditionsByRule(offline, matchedNetworkConditions));
361+
tools.sendCommand(emulateNetworkConditionsByRule(Optional.of(offline), Optional.empty(), matchedNetworkConditions));
362+
}
363+
364+
/**
365+
* Activates emulation of network conditions for individual requests using URL match patterns.
366+
* Unlike the deprecated Network.emulateNetworkConditions this method does not affect `navigator` state.
367+
* Use Network.overrideNetworkState to explicitly modify `navigator` behavior.
368+
*
369+
* @param offline True to emulate internet disconnection.
370+
* @param emulateOfflineServiceWorker True to emulate offline service worker.
371+
* @param matchedNetworkConditions List of network conditions to apply.
372+
*/
373+
public void emulateConditionsByRule(Boolean offline, Boolean emulateOfflineServiceWorker, List<NetworkConditions> matchedNetworkConditions) {
374+
tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()));
375+
tools.sendCommand(emulateNetworkConditionsByRule(Optional.of(offline), Optional.of(emulateOfflineServiceWorker), matchedNetworkConditions));
362376
}
363377

364378
/**

src/test/java/manytools/ManyToolsForm.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package manytools;
22

33
import aquality.selenium.browser.AqualityServices;
4+
import aquality.selenium.core.elements.ElementState;
45
import aquality.selenium.core.utilities.IActionRetrier;
56
import aquality.selenium.elements.interfaces.IButton;
67
import aquality.selenium.elements.interfaces.ILabel;
@@ -12,8 +13,9 @@
1213

1314
public abstract class ManyToolsForm<T extends ManyToolsForm<T>> extends Form {
1415
private static final String BASE_URL = "https://manytools.org/";
15-
private final ILabel lblValue = getFormLabel().findChildElement(By.xpath(".//code"), getName(), ILabel.class);
16-
private final IButton btnAgree = getElementFactory().getButton(By.xpath("//button[@mode='primary']"), "Agree");
16+
private final ILabel lblValue = getFormLabel().findChildElement(By.xpath(".//code"), getName(), ILabel.class, ElementState.EXISTS_IN_ANY_STATE);
17+
private final ILabel lblConsentDialog = getElementFactory().getLabel(By.id("cmpwrapper"), "Cookie consent dialog", ElementState.EXISTS_IN_ANY_STATE);
18+
private final IButton btnDecline = lblConsentDialog.findElementInShadowRoot(By.id("cmpbntnotxt"), "Decline cookies", IButton.class);
1719

1820
protected ManyToolsForm(String name) {
1921
super(By.id("maincontent"), name);
@@ -25,7 +27,13 @@ protected ManyToolsForm(String name) {
2527
public T open() {
2628
AqualityServices.get(IActionRetrier.class).doWithRetry(() -> {
2729
AqualityServices.getBrowser().goTo(BASE_URL + getUrlPart());
30+
state().waitForDisplayed();
2831
}, Collections.singletonList(TimeoutException.class));
32+
33+
if (lblConsentDialog.state().isExist() && btnDecline.state().isDisplayed()) {
34+
btnDecline.click();
35+
lblConsentDialog.state().waitForNotDisplayed();
36+
}
2937
return (T) this;
3038
}
3139

src/test/java/manytools/RequestHeadersForm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public String getValue() {
2323
}
2424

2525
public String getNullableValue(String headerName) {
26-
getFormLabel().state().waitForDisplayed();
26+
getHeaderValueLabel.apply("Accept").state().waitForDisplayed();
2727
ILabel valueLabel = getHeaderValueLabel.apply(headerName);
2828
return valueLabel.state().isDisplayed() ? valueLabel.getText() : null;
2929
}

src/test/java/tests/usecases/devtools/DeviceEmulationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import aquality.selenium.browser.AqualityServices;
44
import aquality.selenium.browser.devtools.EmulationHandling;
55
import com.google.common.collect.ImmutableMap;
6-
import org.openqa.selenium.devtools.v147.emulation.Emulation;
7-
import org.openqa.selenium.devtools.v147.emulation.model.DisplayFeature;
6+
import org.openqa.selenium.devtools.v149.emulation.Emulation;
7+
import org.openqa.selenium.devtools.v149.emulation.model.DisplayFeature;
88
import org.testng.Assert;
99
import org.testng.annotations.BeforeMethod;
1010
import org.testng.annotations.Test;

src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import aquality.selenium.browser.AqualityServices;
44
import aquality.selenium.browser.devtools.NetworkHandling;
55
import org.openqa.selenium.TimeoutException;
6-
import org.openqa.selenium.devtools.v148.network.model.ConnectionType;
7-
import org.openqa.selenium.devtools.v148.network.model.NetworkConditions;
6+
import org.openqa.selenium.devtools.v150.network.model.ConnectionType;
7+
import org.openqa.selenium.devtools.v150.network.model.NetworkConditions;
88
import org.testng.Assert;
99
import org.testng.annotations.Test;
1010
import tests.BaseTest;
@@ -30,11 +30,11 @@ private NetworkHandling network() {
3030

3131
private List<NetworkConditions> getNetworkConditions(int downloadThroughput, int uploadThroughput, ConnectionType connectionType) {
3232
return Collections.singletonList(new NetworkConditions(welcomeForm.getUrl(), LATENCY, downloadThroughput, uploadThroughput,
33-
Optional.of(connectionType), Optional.empty(), Optional.empty(), Optional.empty()));
33+
Optional.of(connectionType), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()));
3434
}
3535
private List<NetworkConditions> getNetworkConditions(int downloadThroughput, int uploadThroughput) {
3636
return Collections.singletonList(new NetworkConditions(welcomeForm.getUrl(), LATENCY, downloadThroughput, uploadThroughput,
37-
Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()));
37+
Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()));
3838
}
3939

4040
@Test
@@ -43,7 +43,7 @@ public void networkSpeedEmulationTest() {
4343
getBrowser().goTo(welcomeForm.getUrl());
4444
Assert.assertTrue(welcomeForm.state().waitForDisplayed(), "Form must be opened");
4545
boolean isOffline = true;
46-
network().emulateConditionsByRule(isOffline, getNetworkConditions(-1, -1));
46+
network().emulateConditionsByRule(isOffline, isOffline, getNetworkConditions(-1, -1));
4747
network().overrideState(isOffline, LATENCY, -1, -1);
4848
getBrowser().refresh();
4949
getBrowser().waitForPageToLoad();

src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import manytools.BrowserLanguageForm;
99
import manytools.UserAgentForm;
1010
import org.openqa.selenium.devtools.idealized.Network;
11-
import org.openqa.selenium.devtools.v147.emulation.Emulation;
11+
import org.openqa.selenium.devtools.v149.emulation.Emulation;
1212
import org.testng.Assert;
1313
import org.testng.annotations.BeforeMethod;
1414
import org.testng.annotations.Test;

0 commit comments

Comments
 (0)