Skip to content

Update to Selenium 4.33.0 +semver:feature #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<dependency>
<groupId>com.github.aquality-automation</groupId>
<artifactId>aquality-selenium-core</artifactId>
<version>4.5.0</version>
<version>4.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.v85.performance.Performance;
import org.openqa.selenium.devtools.v85.performance.model.Metric;
import org.openqa.selenium.devtools.v137.performance.Performance;
import org.openqa.selenium.devtools.v137.performance.model.Metric;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.v85.dom.model.RGBA;
import org.openqa.selenium.devtools.v85.emulation.Emulation;
import org.openqa.selenium.devtools.v85.emulation.model.MediaFeature;
import org.openqa.selenium.devtools.v85.emulation.model.ScreenOrientation;
import org.openqa.selenium.devtools.v137.dom.model.RGBA;
import org.openqa.selenium.devtools.v137.emulation.Emulation;
import org.openqa.selenium.devtools.v137.emulation.model.MediaFeature;
import org.openqa.selenium.devtools.v137.emulation.model.ScreenOrientation;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -45,7 +45,8 @@ public boolean canEmulate() {
* @param accuracy Accuracy of the location
*/
public void setGeolocationOverride(double latitude, double longitude, double accuracy) {
setGeolocationOverride(Optional.of(latitude), Optional.of(longitude), Optional.of(accuracy));
setGeolocationOverride(Optional.of(latitude), Optional.of(longitude), Optional.of(accuracy), Optional.empty(),
Optional.empty(), Optional.empty(), Optional.empty());
}

/**
Expand All @@ -64,8 +65,10 @@ public void setGeolocationOverride(double latitude, double longitude) {
* @param longitude Longitude of location
* @param accuracy Accuracy of the location
*/
public void setGeolocationOverride(Optional<Number> latitude, Optional<Number> longitude, Optional<Number> accuracy) {
tools.sendCommand(Emulation.setGeolocationOverride(latitude, longitude, accuracy));
public void setGeolocationOverride(Optional<Number> latitude, Optional<Number> longitude, Optional<Number> accuracy,
Optional<Number> altitude, Optional<Number> altitudeAccuracy, Optional<Number> heading,
Optional<Number> speed) {
tools.sendCommand(Emulation.setGeolocationOverride(latitude, longitude, accuracy, altitude, altitudeAccuracy, heading, speed));
}

/**
Expand Down Expand Up @@ -115,7 +118,7 @@ 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(), Optional.empty(), screenOrientation, Optional.empty(), Optional.empty(), Optional.empty()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.v85.page.Page;
import org.openqa.selenium.devtools.v85.page.model.ScriptIdentifier;
import org.openqa.selenium.devtools.v85.runtime.Runtime;
import org.openqa.selenium.devtools.v137.page.Page;
import org.openqa.selenium.devtools.v137.page.model.ScriptIdentifier;
import org.openqa.selenium.devtools.v137.runtime.Runtime;
import org.openqa.selenium.logging.EventType;
import org.openqa.selenium.logging.HasLogEvents;
import org.openqa.selenium.remote.Augmenter;
Expand Down Expand Up @@ -55,7 +55,7 @@ public JavaScriptHandling(DevToolsHandling tools) {
public void addScriptCallbackBinding(String scriptName) {
logger.info("loc.browser.javascript.scriptcallbackbinding.add", scriptName);
bindings.add(scriptName);
tools.sendCommand(Runtime.addBinding(scriptName, Optional.empty()));
tools.sendCommand(Runtime.addBinding(scriptName, Optional.empty(), Optional.empty()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.v85.network.model.*;
import org.openqa.selenium.devtools.v137.network.model.*;
import org.openqa.selenium.remote.http.*;

import java.net.URI;
Expand All @@ -22,11 +22,11 @@

import static aquality.selenium.browser.AqualityServices.getBrowser;
import static aquality.selenium.logging.LocalizedLoggerUtility.logByLevel;
import static org.openqa.selenium.devtools.v85.network.Network.*;
import static org.openqa.selenium.devtools.v137.network.Network.*;

/**
* DevTools commands for version-independent network interception.
* For more information, see {@link org.openqa.selenium.devtools.v85.network.Network} and {@link Network}.
* For more information, see {@link org.openqa.selenium.devtools.v137.network.Network} and {@link Network}.
*/
public class NetworkHandling {
public static final String LOC_NETWORK_INTERCEPTOR_START = "loc.browser.network.interceptor.start";
Expand Down Expand Up @@ -199,7 +199,7 @@ private Consumer<ResponseReceived> getResponseLogger(HttpExchangeLoggingOptions
formatHeaders(response.getHeaders()));
}
if (loggingOptions.getResponseBody().isEnabled()) {
String responseBody = tools.sendCommand(org.openqa.selenium.devtools.v85.network.Network.getResponseBody(requestId)).getBody();
String responseBody = tools.sendCommand(org.openqa.selenium.devtools.v137.network.Network.getResponseBody(requestId)).getBody();
if (StringUtils.isNotEmpty(responseBody)) {
logByLevel(loggingOptions.getResponseBody().getLogLevel(),
"loc.browser.network.event.responsereceived.log.body",
Expand Down Expand Up @@ -323,7 +323,8 @@ public void clearNetworkInterceptor() {
*/
public void emulateConditions(Boolean offline, Number latency, Number downloadThroughput, Number uploadThroughput) {
tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty()));
tools.sendCommand(emulateNetworkConditions(offline, latency, downloadThroughput, uploadThroughput, Optional.empty()));
tools.sendCommand(emulateNetworkConditions(offline, latency, downloadThroughput, uploadThroughput, Optional.empty(),
Optional.empty(), Optional.empty(), Optional.empty()));
}

/**
Expand All @@ -339,6 +340,6 @@ public void emulateConditions(Boolean offline, Number latency, Number downloadTh
public void emulateConditions(Boolean offline, Number latency, Number downloadThroughput, Number uploadThroughput, String connectionType) {
tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty()));
tools.sendCommand(emulateNetworkConditions(offline, latency, downloadThroughput, uploadThroughput,
Optional.of(ConnectionType.fromString(connectionType))));
Optional.of(ConnectionType.fromString(connectionType)), Optional.empty(), Optional.empty(), Optional.empty()));
}
}
7 changes: 7 additions & 0 deletions src/test/java/manytools/ManyToolsForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import aquality.selenium.browser.AqualityServices;
import aquality.selenium.core.utilities.IActionRetrier;
import aquality.selenium.elements.interfaces.IButton;
import aquality.selenium.elements.interfaces.ILabel;
import aquality.selenium.forms.Form;
import org.openqa.selenium.By;
Expand All @@ -12,6 +13,7 @@
public abstract class ManyToolsForm<T extends ManyToolsForm<T>> extends Form {
private static final String BASE_URL = "https://manytools.org/";
private final ILabel lblValue = getFormLabel().findChildElement(By.xpath(".//code"), getName(), ILabel.class);
private final IButton btnAgree = getElementFactory().getButton(By.xpath("//button[@mode='primary']"), "Agree");

protected ManyToolsForm(String name) {
super(By.id("maincontent"), name);
Expand All @@ -24,6 +26,11 @@ public T open() {
AqualityServices.get(IActionRetrier.class).doWithRetry(() -> {
AqualityServices.getBrowser().goTo(BASE_URL + getUrlPart());
AqualityServices.getBrowser().waitForPageToLoad();
if (btnAgree.state().isDisplayed())
{
btnAgree.click();
btnAgree.state().waitForNotDisplayed();
}
}, Collections.singletonList(TimeoutException.class));
return (T) this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.v132.emulation.Emulation;
import org.openqa.selenium.devtools.v132.emulation.model.DisplayFeature;
import org.openqa.selenium.devtools.v137.emulation.Emulation;
import org.openqa.selenium.devtools.v137.emulation.model.DisplayFeature;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import aquality.selenium.browser.AqualityServices;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.devtools.v132.network.model.ConnectionType;
import org.openqa.selenium.devtools.v137.network.model.ConnectionType;
import org.testng.Assert;
import org.testng.annotations.Test;
import tests.BaseTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import manytools.BrowserLanguageForm;
import manytools.UserAgentForm;
import org.openqa.selenium.devtools.idealized.Network;
import org.openqa.selenium.devtools.v132.emulation.Emulation;
import org.openqa.selenium.devtools.v137.emulation.Emulation;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand Down
Loading