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.13.0</version>
<version>4.14.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.v145.performance.Performance;
import org.openqa.selenium.devtools.v145.performance.model.Metric;
import org.openqa.selenium.devtools.v147.performance.Performance;
import org.openqa.selenium.devtools.v147.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,13 @@

import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.v145.dom.model.RGBA;
import org.openqa.selenium.devtools.v145.emulation.Emulation;
import org.openqa.selenium.devtools.v145.emulation.model.MediaFeature;
import org.openqa.selenium.devtools.v145.emulation.model.ScreenOrientation;
import org.openqa.selenium.devtools.v147.dom.model.RGBA;
import org.openqa.selenium.devtools.v147.emulation.Emulation;
import org.openqa.selenium.devtools.v147.emulation.model.DevicePosture;
import org.openqa.selenium.devtools.v147.emulation.model.DisplayFeature;
import org.openqa.selenium.devtools.v147.emulation.model.MediaFeature;
import org.openqa.selenium.devtools.v147.emulation.model.ScreenOrientation;
import org.openqa.selenium.devtools.v147.page.model.Viewport;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -130,8 +133,36 @@ 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()));
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(), 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 scale Scale to apply to resulting view image. Ignored if |dontSetVisibleSize| is set.
* @param screenWidth Value to override window.screen.width. Ignored if |dontSetVisibleSize| is set.
* @param screenHeight Value to override window.screen.height. Ignored if |dontSetVisibleSize| is set.
* @param positionX Overriding view X position on screen in device independent pixels (dip). Ignored if |dontSetVisibleSize| is set.
* @param positionY Overriding view Y position on screen in device independent pixels (dip). Ignored if |dontSetVisibleSize| is set.
* @param dontSetVisibleSize Whether to not set visible view size, rely upon explicit setVisibleSize call. Ignored if |scale| is set.
* @param screenOrientation Orientation of the screen. Ignored if |dontSetVisibleSize| is set.
* @param viewport If set, the visible area of the overridden device screen, not affecting the reported screen size. Ignored if |dontSetVisibleSize| is set.
* @param displayFeature Configuration of the display when the system is in unified mode (e.g., foldable devices).
* @param devicePosture The posture of the device (e.g., foldable devices).
* @param scrollbarType The type of the scrollbars to render (e.g., mobile vs desktop). Ignored if |dontSetVisibleSize| is set.
* @param screenOrientationLockEmulation Enables screen orientation lock emulation that intercepts calls to screen.orientation.lock().
*/
public void setDeviceMetricsOverride(Integer width, Integer height, Number deviceScaleFactor, Boolean mobile, Optional<Number> scale, Optional<Integer> screenWidth, Optional<Integer> screenHeight, Optional<Integer> positionX, Optional<Integer> positionY, Optional<Boolean> dontSetVisibleSize, Optional<ScreenOrientation> screenOrientation, Optional<Viewport> viewport, Optional<DisplayFeature> displayFeature, Optional<DevicePosture> devicePosture, Optional<Emulation.SetDeviceMetricsOverrideScrollbarType> scrollbarType, Optional<Boolean> screenOrientationLockEmulation) {
tools.sendCommand(Emulation.setDeviceMetricsOverride(width, height, deviceScaleFactor, mobile, scale, screenWidth,
screenHeight, positionX, positionY, dontSetVisibleSize, screenOrientation, viewport, displayFeature,
devicePosture, scrollbarType, screenOrientationLockEmulation));
}

/**
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.v145.page.Page;
import org.openqa.selenium.devtools.v145.page.model.ScriptIdentifier;
import org.openqa.selenium.devtools.v145.runtime.Runtime;
import org.openqa.selenium.devtools.v147.page.Page;
import org.openqa.selenium.devtools.v147.page.model.ScriptIdentifier;
import org.openqa.selenium.devtools.v147.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.v145.network.model.*;
import org.openqa.selenium.devtools.v147.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.v145.network.Network.*;
import static org.openqa.selenium.devtools.v147.network.Network.*;

/**
* DevTools commands for version-independent network interception.
* For more information, see {@link org.openqa.selenium.devtools.v145.network.Network} and {@link Network}.
* For more information, see {@link org.openqa.selenium.devtools.v147.network.Network} and {@link Network}.
*/
public class NetworkHandling {
public static final String LOC_NETWORK_INTERCEPTOR_START = "loc.browser.network.interceptor.start";
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.v144.emulation.Emulation;
import org.openqa.selenium.devtools.v144.emulation.model.DisplayFeature;
import org.openqa.selenium.devtools.v146.emulation.Emulation;
import org.openqa.selenium.devtools.v146.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 @@ -3,8 +3,8 @@
import aquality.selenium.browser.AqualityServices;
import aquality.selenium.browser.devtools.NetworkHandling;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.devtools.v145.network.model.ConnectionType;
import org.openqa.selenium.devtools.v145.network.model.NetworkConditions;
import org.openqa.selenium.devtools.v147.network.model.ConnectionType;
import org.openqa.selenium.devtools.v147.network.model.NetworkConditions;
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.v144.emulation.Emulation;
import org.openqa.selenium.devtools.v146.emulation.Emulation;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand Down
Loading