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
10 changes: 5 additions & 5 deletions 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.15.0</version>
<version>4.16.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -80,7 +80,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.21.3</version>
<version>2.22.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -116,7 +116,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.14</version>
<version>0.8.15</version>
<executions>
<execution>
<id>pre-unit-test</id>
Expand Down Expand Up @@ -144,7 +144,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.5</version>
<version>3.5.6</version>
<configuration>
<argLine>${surefireArgLine} -Dfile.encoding=UTF-8</argLine>
<reuseForks>false</reuseForks>
Expand Down Expand Up @@ -223,7 +223,7 @@
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.10.0</version>
<version>0.11.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
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.v148.performance.Performance;
import org.openqa.selenium.devtools.v148.performance.model.Metric;
import org.openqa.selenium.devtools.v150.performance.Performance;
import org.openqa.selenium.devtools.v150.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,13 +2,13 @@

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

import java.util.Collections;
import java.util.List;
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.v148.page.Page;
import org.openqa.selenium.devtools.v148.page.model.ScriptIdentifier;
import org.openqa.selenium.devtools.v148.runtime.Runtime;
import org.openqa.selenium.devtools.v150.page.Page;
import org.openqa.selenium.devtools.v150.page.model.ScriptIdentifier;
import org.openqa.selenium.devtools.v150.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.v148.network.model.*;
import org.openqa.selenium.devtools.v150.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.v148.network.Network.*;
import static org.openqa.selenium.devtools.v150.network.Network.*;

/**
* DevTools commands for version-independent network interception.
* For more information, see {@link org.openqa.selenium.devtools.v148.network.Network} and {@link Network}.
* For more information, see {@link org.openqa.selenium.devtools.v150.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 @@ -358,7 +358,21 @@ public void emulateConditions(Boolean offline, Number latency, Number downloadTh
*/
public void emulateConditionsByRule(Boolean offline, List<NetworkConditions> matchedNetworkConditions) {
tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()));
tools.sendCommand(emulateNetworkConditionsByRule(offline, matchedNetworkConditions));
tools.sendCommand(emulateNetworkConditionsByRule(Optional.of(offline), Optional.empty(), matchedNetworkConditions));
}

/**
* Activates emulation of network conditions for individual requests using URL match patterns.
* Unlike the deprecated Network.emulateNetworkConditions this method does not affect `navigator` state.
* Use Network.overrideNetworkState to explicitly modify `navigator` behavior.
*
* @param offline True to emulate internet disconnection.
* @param emulateOfflineServiceWorker True to emulate offline service worker.
* @param matchedNetworkConditions List of network conditions to apply.
*/
public void emulateConditionsByRule(Boolean offline, Boolean emulateOfflineServiceWorker, List<NetworkConditions> matchedNetworkConditions) {
tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()));
tools.sendCommand(emulateNetworkConditionsByRule(Optional.of(offline), Optional.of(emulateOfflineServiceWorker), matchedNetworkConditions));
}

/**
Expand Down
12 changes: 10 additions & 2 deletions src/test/java/manytools/ManyToolsForm.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package manytools;

import aquality.selenium.browser.AqualityServices;
import aquality.selenium.core.elements.ElementState;
import aquality.selenium.core.utilities.IActionRetrier;
import aquality.selenium.elements.interfaces.IButton;
import aquality.selenium.elements.interfaces.ILabel;
Expand All @@ -12,8 +13,9 @@

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");
private final ILabel lblValue = getFormLabel().findChildElement(By.xpath(".//code"), getName(), ILabel.class, ElementState.EXISTS_IN_ANY_STATE);
private final ILabel lblConsentDialog = getElementFactory().getLabel(By.id("cmpwrapper"), "Cookie consent dialog", ElementState.EXISTS_IN_ANY_STATE);
private final IButton btnDecline = lblConsentDialog.findElementInShadowRoot(By.id("cmpbntnotxt"), "Decline cookies", IButton.class);

protected ManyToolsForm(String name) {
super(By.id("maincontent"), name);
Expand All @@ -25,7 +27,13 @@ protected ManyToolsForm(String name) {
public T open() {
AqualityServices.get(IActionRetrier.class).doWithRetry(() -> {
AqualityServices.getBrowser().goTo(BASE_URL + getUrlPart());
state().waitForDisplayed();
}, Collections.singletonList(TimeoutException.class));

if (lblConsentDialog.state().isExist() && btnDecline.state().isDisplayed()) {
btnDecline.click();
lblConsentDialog.state().waitForNotDisplayed();
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
return (T) this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/manytools/RequestHeadersForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public String getValue() {
}

public String getNullableValue(String headerName) {
getFormLabel().state().waitForDisplayed();
getHeaderValueLabel.apply("Accept").state().waitForDisplayed();
Comment thread
coderabbitai[bot] marked this conversation as resolved.
ILabel valueLabel = getHeaderValueLabel.apply(headerName);
return valueLabel.state().isDisplayed() ? valueLabel.getText() : null;
}
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.v147.emulation.Emulation;
import org.openqa.selenium.devtools.v147.emulation.model.DisplayFeature;
import org.openqa.selenium.devtools.v149.emulation.Emulation;
import org.openqa.selenium.devtools.v149.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.v148.network.model.ConnectionType;
import org.openqa.selenium.devtools.v148.network.model.NetworkConditions;
import org.openqa.selenium.devtools.v150.network.model.ConnectionType;
import org.openqa.selenium.devtools.v150.network.model.NetworkConditions;
import org.testng.Assert;
import org.testng.annotations.Test;
import tests.BaseTest;
Expand All @@ -30,11 +30,11 @@ private NetworkHandling network() {

private List<NetworkConditions> getNetworkConditions(int downloadThroughput, int uploadThroughput, ConnectionType connectionType) {
return Collections.singletonList(new NetworkConditions(welcomeForm.getUrl(), LATENCY, downloadThroughput, uploadThroughput,
Optional.of(connectionType), Optional.empty(), Optional.empty(), Optional.empty()));
Optional.of(connectionType), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()));
}
private List<NetworkConditions> getNetworkConditions(int downloadThroughput, int uploadThroughput) {
return Collections.singletonList(new NetworkConditions(welcomeForm.getUrl(), LATENCY, downloadThroughput, uploadThroughput,
Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()));
Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()));
}

@Test
Expand All @@ -43,7 +43,7 @@ public void networkSpeedEmulationTest() {
getBrowser().goTo(welcomeForm.getUrl());
Assert.assertTrue(welcomeForm.state().waitForDisplayed(), "Form must be opened");
boolean isOffline = true;
network().emulateConditionsByRule(isOffline, getNetworkConditions(-1, -1));
network().emulateConditionsByRule(isOffline, isOffline, getNetworkConditions(-1, -1));
network().overrideState(isOffline, LATENCY, -1, -1);
getBrowser().refresh();
getBrowser().waitForPageToLoad();
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.v147.emulation.Emulation;
import org.openqa.selenium.devtools.v149.emulation.Emulation;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand Down
Loading