Skip to content
Merged
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 @@ -70,7 +70,7 @@
<dependency>
<groupId>com.github.aquality-automation</groupId>
<artifactId>aquality-selenium-core</artifactId>
<version>4.8.0</version>
<version>4.9.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.v138.performance.Performance;
import org.openqa.selenium.devtools.v138.performance.model.Metric;
import org.openqa.selenium.devtools.v140.performance.Performance;
import org.openqa.selenium.devtools.v140.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.v138.dom.model.RGBA;
import org.openqa.selenium.devtools.v138.emulation.Emulation;
import org.openqa.selenium.devtools.v138.emulation.model.MediaFeature;
import org.openqa.selenium.devtools.v138.emulation.model.ScreenOrientation;
import org.openqa.selenium.devtools.v140.dom.model.RGBA;
import org.openqa.selenium.devtools.v140.emulation.Emulation;
import org.openqa.selenium.devtools.v140.emulation.model.MediaFeature;
import org.openqa.selenium.devtools.v140.emulation.model.ScreenOrientation;

import java.util.Collections;
import java.util.List;
Expand All @@ -24,6 +24,7 @@ public class EmulationHandling {

/**
* Initializes a new instance of the {@link NetworkHandling} class.
*
* @param tools Instance of {@link DevToolsHandling}.
*/
public EmulationHandling(DevToolsHandling tools) {
Expand All @@ -32,17 +33,20 @@ public EmulationHandling(DevToolsHandling tools) {

/**
* Tells whether emulation is supported.
*
* @return true if the emulation is supported, false otherwise.
*/
@Deprecated
public boolean canEmulate() {
return tools.sendCommand(Emulation.canEmulate());
}

/**
* Overrides the GeoLocation Position or Error. Omitting any of the parameters emulates position unavailable.
* @param latitude Latitude of location
*
* @param latitude Latitude of location
* @param longitude Longitude of location
* @param accuracy Accuracy of the location
* @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), Optional.empty(),
Expand All @@ -52,7 +56,8 @@ public void setGeolocationOverride(double latitude, double longitude, double acc
/**
* Overrides the GeoLocation Position. Accuracy of the geoLocation is set to 1 meaning 100% accuracy.
* Omitting any of the parameters emulates position unavailable.
* @param latitude Latitude of location
*
* @param latitude Latitude of location
* @param longitude Longitude of location
*/
public void setGeolocationOverride(double latitude, double longitude) {
Expand All @@ -61,9 +66,14 @@ public void setGeolocationOverride(double latitude, double longitude) {

/**
* Overrides the GeoLocation Position or Error. Omitting any of the parameters emulates position unavailable.
* @param latitude Latitude of location
* @param longitude Longitude of location
* @param accuracy Accuracy of the location
*
* @param latitude Latitude of location
* @param longitude Longitude of location
* @param altitude Altitude of location
* @param accuracy Accuracy of the location
* @param altitudeAccuracy Altitude accuracy of the location
* @param heading Heading of location
* @param speed Speed of location
*/
public void setGeolocationOverride(Optional<Number> latitude, Optional<Number> longitude, Optional<Number> accuracy,
Optional<Number> altitude, Optional<Number> altitudeAccuracy, Optional<Number> heading,
Expand All @@ -80,6 +90,7 @@ public void clearGeolocationOverride() {

/**
* Overrides the values of device screen dimensions.
*
* @param params Version-specific set of parameters. For example, take a look at {@link Emulation#setDeviceMetricsOverride}
*/
public void setDeviceMetricsOverride(Map<String, Object> params) {
Expand All @@ -88,23 +99,25 @@ public void setDeviceMetricsOverride(Map<String, Object> params) {

/**
* Overrides the values of device screen dimensions.
* @param width Value to override window.screen.width
* @param height Value to override window.screen.height
*
* @param width Value to override window.screen.width
* @param height Value to override window.screen.height
* @param deviceScaleFactor Overriding device scale factor value. 0 disables the override.
* @param mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text auto-sizing and more.
* @param mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text auto-sizing and more.
*/
public void setDeviceMetricsOverride(Integer width, Integer height, Number deviceScaleFactor, Boolean mobile) {
setDeviceMetricsOverride(width, height, deviceScaleFactor, mobile, Optional.empty(), Optional.empty());
}

/**
* Overrides the values of device screen dimensions.
* @param width Value to override window.screen.width
* @param height Value to override window.screen.height
* @param deviceScaleFactor Overriding device scale factor value. 0 disables the override.
* @param mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text auto-sizing and more.
* @param screenOrientationType Orientation type.
* Allowed Values (in any case): portraitPrimary, portraitSecondary, landscapePrimary, landscapeSecondary.
*
* @param width Value to override window.screen.width
* @param height Value to override window.screen.height
* @param deviceScaleFactor Overriding device scale factor value. 0 disables the override.
* @param mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text auto-sizing and more.
* @param screenOrientationType Orientation type.
* Allowed Values (in any case): portraitPrimary, portraitSecondary, landscapePrimary, landscapeSecondary.
* @param screenOrientationAngle Orientation angle. Set only if orientation type was set.
*/
public void setDeviceMetricsOverride(Integer width, Integer height, Number deviceScaleFactor, Boolean mobile,
Expand All @@ -130,6 +143,7 @@ public void clearDeviceMetricsOverride() {

/**
* Overrides the values of user agent.
*
* @param params Version-specific set of parameters.
* For example, take a look at {@link Emulation#setUserAgentOverride}
*/
Expand All @@ -139,6 +153,7 @@ public void setUserAgentOverride(Map<String, Object> params) {

/**
* Overrides the values of user agent.
*
* @param userAgent User agent to use.
*/
public void setUserAgentOverride(String userAgent) {
Expand All @@ -147,9 +162,10 @@ public void setUserAgentOverride(String userAgent) {

/**
* Overrides the values of user agent.
* @param userAgent User agent to use.
*
* @param userAgent User agent to use.
* @param acceptLanguage Browser language to emulate.
* @param platform The platform navigator.platform should return.
* @param platform The platform navigator.platform should return.
*/
public void setUserAgentOverride(String userAgent, Optional<String> acceptLanguage, Optional<String> platform) {
tools.sendCommand(Emulation.setUserAgentOverride(userAgent, acceptLanguage, platform, Optional.empty()));
Expand All @@ -164,6 +180,7 @@ public void setScriptExecutionDisabled() {

/**
* Switches script execution in the page.
*
* @param value Whether script execution should be disabled in the page.
*/
public void setScriptExecutionDisabled(boolean value) {
Expand All @@ -179,6 +196,7 @@ public void setTouchEmulationEnabled() {

/**
* Enables touch on platforms which do not support them.
*
* @param enabled Whether the touch event emulation should be enabled.
*/
public void setTouchEmulationEnabled(boolean enabled) {
Expand All @@ -187,7 +205,8 @@ public void setTouchEmulationEnabled(boolean enabled) {

/**
* Enables touch on platforms which do not support them.
* @param enabled Whether the touch event emulation should be enabled.
*
* @param enabled Whether the touch event emulation should be enabled.
* @param maxTouchPoints Maximum touch points supported. Defaults to one.
*/
public void setTouchEmulationEnabled(boolean enabled, Optional<Integer> maxTouchPoints) {
Expand All @@ -196,6 +215,7 @@ public void setTouchEmulationEnabled(boolean enabled, Optional<Integer> maxTouch

/**
* Emulates the given media type or media feature for CSS media queries.
*
* @param params Version-specific set of parameters. For example, take a look at {@link Emulation#setEmulatedMedia}
*/
public void setEmulatedMedia(Map<String, Object> params) {
Expand All @@ -204,8 +224,9 @@ public void setEmulatedMedia(Map<String, Object> params) {

/**
* Emulates the given media type or media feature for CSS media queries.
* @param media Media type to emulate. Empty string disables the override.
* Possible values: braille, embossed, handheld, print, projection, screen, speech, tty, tv.
*
* @param media Media type to emulate. Empty string disables the override.
* Possible values: braille, embossed, handheld, print, projection, screen, speech, tty, tv.
* @param mediaFeatures Media features to emulate.
*/
public void setEmulatedMedia(String media, Map<String, String> mediaFeatures) {
Expand All @@ -214,8 +235,9 @@ public void setEmulatedMedia(String media, Map<String, String> mediaFeatures) {

/**
* Emulates the given media type or media feature for CSS media queries.
* @param media Media type to emulate. Empty string disables the override.
* Possible values: braille, embossed, handheld, print, projection, screen, speech, tty, tv.
*
* @param media Media type to emulate. Empty string disables the override.
* Possible values: braille, embossed, handheld, print, projection, screen, speech, tty, tv.
* @param mediaFeatures Media features to emulate.
*/
public void setEmulatedMedia(Optional<String> media, Optional<Map<String, String>> mediaFeatures) {
Expand All @@ -233,19 +255,21 @@ public void disableEmulatedMediaOverride() {

/**
* Sets an override of the default background color of the frame. This override is used if the content does not specify one.
* @param red The red component, in the [0-255] range.
*
* @param red The red component, in the [0-255] range.
* @param green The green component, in the [0-255] range.
* @param blue The blue component, in the [0-255] range.
* @param blue The blue component, in the [0-255] range.
*/
public void setDefaultBackgroundColorOverride(int red, int green, int blue) {
setDefaultBackgroundColorOverride(red, green, blue, Optional.empty());
}

/**
* Sets an override of the default background color of the frame. This override is used if the content does not specify one.
* @param red The red component, in the [0-255] range.
*
* @param red The red component, in the [0-255] range.
* @param green The green component, in the [0-255] range.
* @param blue The blue component, in the [0-255] range.
* @param blue The blue component, in the [0-255] range.
* @param alpha The alpha component, in the [0-1] range (default: 1).
*/
public void setDefaultBackgroundColorOverride(int red, int green, int blue, Optional<Number> alpha) {
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.v138.page.Page;
import org.openqa.selenium.devtools.v138.page.model.ScriptIdentifier;
import org.openqa.selenium.devtools.v138.runtime.Runtime;
import org.openqa.selenium.devtools.v140.page.Page;
import org.openqa.selenium.devtools.v140.page.model.ScriptIdentifier;
import org.openqa.selenium.devtools.v140.runtime.Runtime;
import org.openqa.selenium.logging.EventType;
import org.openqa.selenium.logging.HasLogEvents;
import org.openqa.selenium.remote.Augmenter;
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.v138.network.model.*;
import org.openqa.selenium.devtools.v140.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.v138.network.Network.*;
import static org.openqa.selenium.devtools.v140.network.Network.*;

/**
* DevTools commands for version-independent network interception.
* For more information, see {@link org.openqa.selenium.devtools.v138.network.Network} and {@link Network}.
* For more information, see {@link org.openqa.selenium.devtools.v140.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 @@ -80,6 +80,7 @@ public void setUserAgent(Network.UserAgent userAgent) {

/**
* Add basic authentication handler.
* @param whenThisMatches URI matcher.
* @param useTheseCredentials parameters, such as URI matcher and credentials.
*/
public void addAuthHandler(Predicate<URI> whenThisMatches, Supplier<Credentials> useTheseCredentials) {
Expand Down Expand Up @@ -199,7 +200,7 @@ private Consumer<ResponseReceived> getResponseLogger(HttpExchangeLoggingOptions
formatHeaders(response.getHeaders()));
}
if (loggingOptions.getResponseBody().isEnabled()) {
String responseBody = tools.sendCommand(org.openqa.selenium.devtools.v138.network.Network.getResponseBody(requestId)).getBody();
String responseBody = tools.sendCommand(org.openqa.selenium.devtools.v140.network.Network.getResponseBody(requestId)).getBody();
if (StringUtils.isNotEmpty(responseBody)) {
logByLevel(loggingOptions.getResponseBody().getLogLevel(),
"loc.browser.network.event.responsereceived.log.body",
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/aquality/selenium/elements/actions/JsActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public SearchContext expandShadowRoot() {

/**
* Setting attribute value.
* @param name Attribute name
*
* @param name Attribute name
* @param value Value to set
*/
public void setAttribute(String name, String value) {
Expand Down Expand Up @@ -69,6 +70,8 @@ public void highlightElement() {

/**
* Highlights the element.
*
* @param highlightState Highlight state
*/
public void highlightElement(HighlightState highlightState) {
if ((AqualityServices.getBrowserProfile().isElementHighlightEnabled() && !highlightState.equals(HighlightState.NOT_HIGHLIGHT))
Expand Down Expand Up @@ -186,7 +189,9 @@ private Object[] resolveArguments(Object... args) {

/**
* Executes pinned JavaScript against the element and gets result value.
*
* @param pinnedScript Instance of script pinned with {@link Browser#javaScriptEngine()}
* @param args Script arguments.
* @return Script execution result.
*/
public Object executeScript(ScriptKey pinnedScript, Object... args) {
Expand All @@ -209,7 +214,8 @@ protected Object executeScript(JavaScript javaScript, Object... args) {
/**
* The implementation of a method for logging of Javascript actions
*
* @param key key in localization resource of message to display in the log.
* @param key key in localization resource of message to display in the log.
* @param args arguments for message formatting.
*/
protected void logElementAction(String key, Object... args) {
AqualityServices.getLocalizedLogger().infoElementAction(type, name, key, args);
Expand Down
Loading
Loading