From d4e0fa865a7179929157f563ed52ef022b0a90e9 Mon Sep 17 00:00:00 2001 From: Aliaksej Mialeshka Date: Tue, 30 Dec 2025 20:42:24 +0100 Subject: [PATCH 1/2] Update to Selenium 4.39.0 +semver:feature Update DevTools references to use V143 in tests --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8cfece3..db437c6 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ com.github.aquality-automation aquality-selenium-core - 4.10.0 + 4.11.0 org.apache.commons From a8381e999282cb8e2c15f4a053078937bbbab3c7 Mon Sep 17 00:00:00 2001 From: Aliaksej Mialeshka Date: Wed, 31 Dec 2025 13:29:03 +0100 Subject: [PATCH 2/2] Update tests, update w3c schools locators for multiselect form, update geolocation override test Update DevTools references to use V143 in the library and V142 in tests Update commons-lang3 reference --- pom.xml | 4 +- .../browser/devtools/DevToolsHandling.java | 4 +- .../browser/devtools/EmulationHandling.java | 8 +- .../browser/devtools/JavaScriptHandling.java | 6 +- .../browser/devtools/NetworkHandling.java | 100 ++++++++++++++---- .../java/automationpractice/Constants.java | 2 +- src/test/java/forms/MyLocationForm.java | 8 +- .../devtools/DeviceEmulationTest.java | 4 +- .../devtools/NetworkSpeedEmulationTest.java | 32 +++++- .../devtools/OverrideGeolocationTest.java | 4 +- .../devtools/OverrideUserAgentTest.java | 2 +- .../w3schools/forms/SelectMultipleForm.java | 13 ++- 12 files changed, 140 insertions(+), 47 deletions(-) diff --git a/pom.xml b/pom.xml index db437c6..d252f51 100644 --- a/pom.xml +++ b/pom.xml @@ -70,12 +70,12 @@ com.github.aquality-automation aquality-selenium-core - 4.11.0 + 4.11.1 org.apache.commons commons-lang3 - 3.18.0 + 3.20.0 com.fasterxml.jackson.core diff --git a/src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java b/src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java index 095eff7..b4cd0a0 100644 --- a/src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java +++ b/src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java @@ -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.v142.performance.Performance; -import org.openqa.selenium.devtools.v142.performance.model.Metric; +import org.openqa.selenium.devtools.v143.performance.Performance; +import org.openqa.selenium.devtools.v143.performance.model.Metric; import java.util.List; import java.util.Map; diff --git a/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java b/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java index 6314b53..55bba05 100644 --- a/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java +++ b/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java @@ -2,10 +2,10 @@ import org.apache.commons.lang3.StringUtils; import org.openqa.selenium.devtools.Command; -import org.openqa.selenium.devtools.v142.dom.model.RGBA; -import org.openqa.selenium.devtools.v142.emulation.Emulation; -import org.openqa.selenium.devtools.v142.emulation.model.MediaFeature; -import org.openqa.selenium.devtools.v142.emulation.model.ScreenOrientation; +import org.openqa.selenium.devtools.v143.dom.model.RGBA; +import org.openqa.selenium.devtools.v143.emulation.Emulation; +import org.openqa.selenium.devtools.v143.emulation.model.MediaFeature; +import org.openqa.selenium.devtools.v143.emulation.model.ScreenOrientation; import java.util.Collections; import java.util.List; diff --git a/src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java b/src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java index de6a1c1..a89cadd 100644 --- a/src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java +++ b/src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java @@ -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.v142.page.Page; -import org.openqa.selenium.devtools.v142.page.model.ScriptIdentifier; -import org.openqa.selenium.devtools.v142.runtime.Runtime; +import org.openqa.selenium.devtools.v143.page.Page; +import org.openqa.selenium.devtools.v143.page.model.ScriptIdentifier; +import org.openqa.selenium.devtools.v143.runtime.Runtime; import org.openqa.selenium.logging.EventType; import org.openqa.selenium.logging.HasLogEvents; import org.openqa.selenium.remote.Augmenter; diff --git a/src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java b/src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java index 57aa196..bef2318 100644 --- a/src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java +++ b/src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java @@ -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.v142.network.model.*; +import org.openqa.selenium.devtools.v143.network.model.*; import org.openqa.selenium.remote.http.*; import java.net.URI; @@ -22,11 +22,11 @@ import static aquality.selenium.browser.AqualityServices.getBrowser; import static aquality.selenium.logging.LocalizedLoggerUtility.logByLevel; -import static org.openqa.selenium.devtools.v142.network.Network.*; +import static org.openqa.selenium.devtools.v143.network.Network.*; /** * DevTools commands for version-independent network interception. - * For more information, see {@link org.openqa.selenium.devtools.v142.network.Network} and {@link Network}. + * For more information, see {@link org.openqa.selenium.devtools.v143.network.Network} and {@link Network}. */ public class NetworkHandling { public static final String LOC_NETWORK_INTERCEPTOR_START = "loc.browser.network.interceptor.start"; @@ -62,6 +62,7 @@ public void stopMonitoring() { /** * Overrides the values of user agent. + * * @param userAgent User agent to use. */ public void setUserAgent(String userAgent) { @@ -71,6 +72,7 @@ public void setUserAgent(String userAgent) { /** * Overrides the values of user agent. + * * @param userAgent User agent to use. */ public void setUserAgent(Network.UserAgent userAgent) { @@ -80,7 +82,8 @@ public void setUserAgent(Network.UserAgent userAgent) { /** * Add basic authentication handler. - * @param whenThisMatches URI matcher. + * + * @param whenThisMatches URI matcher. * @param useTheseCredentials parameters, such as URI matcher and credentials. */ public void addAuthHandler(Predicate whenThisMatches, Supplier useTheseCredentials) { @@ -90,6 +93,7 @@ public void addAuthHandler(Predicate whenThisMatches, Supplier /** * Add basic authentication handler. + * * @param hostPart part of the host name for URI matcher. * @param username authentication username. * @param password authentication password. @@ -117,6 +121,7 @@ public void resetNetworkFilter() { /** * Starts traffic interception with specified filter. + * * @param filter HTTP filter. */ public void interceptTrafficWith(Filter filter) { @@ -126,6 +131,7 @@ public void interceptTrafficWith(Filter filter) { /** * Adds listener to network request sent event. + * * @param listener a listener to add. */ public void addRequestListener(Consumer listener) { @@ -136,6 +142,7 @@ public void addRequestListener(Consumer listener) { /** * Adds listener to network response received event. + * * @param listener a listener to add. */ public void addResponseListener(Consumer listener) { @@ -200,7 +207,7 @@ private Consumer getResponseLogger(HttpExchangeLoggingOptions formatHeaders(response.getHeaders())); } if (loggingOptions.getResponseBody().isEnabled()) { - String responseBody = tools.sendCommand(org.openqa.selenium.devtools.v142.network.Network.getResponseBody(requestId)).getBody(); + String responseBody = tools.sendCommand(getResponseBody(requestId)).getBody(); if (StringUtils.isNotEmpty(responseBody)) { logByLevel(loggingOptions.getResponseBody().getLogLevel(), "loc.browser.network.event.responsereceived.log.body", @@ -212,6 +219,7 @@ private Consumer getResponseLogger(HttpExchangeLoggingOptions /** * Enables HTTP Request/Response logging. + * * @param loggingOptions logging parameters {@link HttpExchangeLoggingOptions}. */ public void enableHttpExchangeLogging(HttpExchangeLoggingOptions loggingOptions) { @@ -221,6 +229,7 @@ public void enableHttpExchangeLogging(HttpExchangeLoggingOptions loggingOptions) /** * Starts network interceptor. + * * @param httpHandler HTTP handler. * @return an instance of {@link NetworkInterceptor}. */ @@ -231,6 +240,7 @@ public NetworkInterceptor startNetworkInterceptor(HttpHandler httpHandler) { /** * Starts network interceptor. + * * @param filter network filter. * @return an instance of {@link NetworkInterceptor}. */ @@ -241,6 +251,7 @@ public NetworkInterceptor startNetworkInterceptor(Filter filter) { /** * Starts network interceptor. + * * @param routable a filter with matcher. * @return an instance of {@link NetworkInterceptor}. */ @@ -251,8 +262,9 @@ public NetworkInterceptor startNetworkInterceptor(Routable routable) { /** * Starts network interceptor. + * * @param requestMatcher predicate to match the request. - * @param handler handler for matched requests. + * @param handler handler for matched requests. * @return an instance of {@link NetworkInterceptor}. */ public NetworkInterceptor startNetworkInterceptor(Predicate requestMatcher, Supplier handler) { @@ -261,6 +273,7 @@ public NetworkInterceptor startNetworkInterceptor(Predicate request /** * Intercepts any request with predefined response. + * * @param response HTTP response. * @return an instance of {@link NetworkInterceptor}. */ @@ -270,7 +283,8 @@ public NetworkInterceptor interceptAllRequests(HttpResponse response) { /** * Adds request transformer. - * @param requestMatcher predicate to match the request. + * + * @param requestMatcher predicate to match the request. * @param requestTransformer function to transform the request. * @return an instance of {@link NetworkInterceptor}. */ @@ -281,6 +295,7 @@ public NetworkInterceptor addRequestTransformer(Predicate requestMa /** * Adds request handler. + * * @param requestMatcher predicate to match the request. * @param requestHandler handler for matched requests. * @return an instance of {@link NetworkInterceptor}. @@ -292,7 +307,8 @@ public NetworkInterceptor addRequestHandler(Predicate requestMatche /** * Adds response handler. - * @param responseMatcher predicate to match the response. + * + * @param responseMatcher predicate to match the response. * @param responseTransformer function to transform the response. * @return an instance of {@link NetworkInterceptor}. */ @@ -309,7 +325,7 @@ public NetworkInterceptor addResponseHandler(Predicate responseMat * Currently, Selenium supports only a single network interceptor. Any new Network interceptor will override the previous one. * And on {@link NetworkInterceptor#close()} the NetworkInterceptor class just calls the {@link Network#resetNetworkFilter()}, so it's enough to call it. * If multiple network interceptors at the same time would be allowed, we may want to store all - * {@link NetworkInterceptor} classes to call {@link NetworkInterceptor#close()} for each. + * {@link NetworkInterceptor} classes to call {@link NetworkInterceptor#close()} for each. */ public void clearNetworkInterceptor() { resetNetworkFilter(); @@ -317,27 +333,75 @@ public void clearNetworkInterceptor() { /** * Activates emulation of network conditions. - * @param offline True to emulate internet disconnection. - * @param latency Minimum latency from request sent to response headers received (ms). + * + * @param offline True to emulate internet disconnection. + * @param latency Minimum latency from request sent to response headers received (ms). * @param downloadThroughput Maximal aggregated download throughput (bytes/sec). -1 disables download throttling. - * @param uploadThroughput Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. + * @param uploadThroughput Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. + * @deprecated This command is deprecated in favor of the {@link #emulateConditionsByRule(Boolean, List)} + * and {@link #overrideState} commands, which can be used together to the same effect. */ + @Deprecated public void emulateConditions(Boolean offline, Number latency, Number downloadThroughput, Number uploadThroughput) { tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty())); tools.sendCommand(emulateNetworkConditions(offline, latency, downloadThroughput, uploadThroughput, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty())); } + /** + * 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 matchedNetworkConditions List of network conditions to apply. + */ + public void emulateConditionsByRule(Boolean offline, List matchedNetworkConditions) { + tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty())); + tools.sendCommand(emulateNetworkConditionsByRule(offline, matchedNetworkConditions)); + } + + /** + * Override the state of navigator.onLine and navigator.connection. + * + * @param offline True to emulate internet disconnection. + * @param latency Minimum latency from request sent to response headers received (ms). + * @param downloadThroughput Maximal aggregated download throughput (bytes/sec). -1 disables download throttling. + * @param uploadThroughput Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. + */ + public void overrideState(Boolean offline, Number latency, Number downloadThroughput, Number uploadThroughput) { + tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty())); + tools.sendCommand(overrideNetworkState(offline, latency, downloadThroughput, uploadThroughput, Optional.empty())); + } + + /** + * Override the state of navigator.onLine and navigator.connection. + * + * @param offline True to emulate internet disconnection. + * @param latency Minimum latency from request sent to response headers received (ms). + * @param downloadThroughput Maximal aggregated download throughput (bytes/sec). -1 disables download throttling. + * @param uploadThroughput Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. + * @param connectionType Connection type if known. + */ + public void overrideState(Boolean offline, Number latency, Number downloadThroughput, Number uploadThroughput, ConnectionType connectionType) { + tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty())); + tools.sendCommand(overrideNetworkState(offline, latency, downloadThroughput, uploadThroughput, Optional.of(connectionType))); + } + /** * Activates emulation of network conditions. - * @param offline True to emulate internet disconnection. - * @param latency Minimum latency from request sent to response headers received (ms). + * + * @param offline True to emulate internet disconnection. + * @param latency Minimum latency from request sent to response headers received (ms). * @param downloadThroughput Maximal aggregated download throughput (bytes/sec). -1 disables download throttling. - * @param uploadThroughput Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. - * @param connectionType Connection type if known. - * Possible values: "none", "cellular2g", "cellular3g", "cellular4g", "bluetooth", "ethernet", - * "wifi", "wimax", "other". + * @param uploadThroughput Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. + * @param connectionType Connection type if known. + * Possible values: "none", "cellular2g", "cellular3g", "cellular4g", "bluetooth", "ethernet", + * "wifi", "wimax", "other". + * @deprecated This command is deprecated in favor of the {@link #emulateConditionsByRule(Boolean, List)} + * and {@link #overrideState} commands, which can be used together to the same effect. */ + @Deprecated public void emulateConditions(Boolean offline, Number latency, Number downloadThroughput, Number uploadThroughput, String connectionType) { tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty())); tools.sendCommand(emulateNetworkConditions(offline, latency, downloadThroughput, uploadThroughput, diff --git a/src/test/java/automationpractice/Constants.java b/src/test/java/automationpractice/Constants.java index a8cd59d..c9c9746 100644 --- a/src/test/java/automationpractice/Constants.java +++ b/src/test/java/automationpractice/Constants.java @@ -5,5 +5,5 @@ private Constants(){ } public static final String URL_AUTOMATIONPRACTICE = "http://automationpractice.com/index.php"; - public static final String URL_MYLOCATIONORG = "https://my-location.org"; + public static final String URL_MYLOCATIONORG = "https://whereamirightnow.org"; } diff --git a/src/test/java/forms/MyLocationForm.java b/src/test/java/forms/MyLocationForm.java index 2d94aed..91e663b 100644 --- a/src/test/java/forms/MyLocationForm.java +++ b/src/test/java/forms/MyLocationForm.java @@ -7,12 +7,12 @@ public class MyLocationForm extends Form { - private final ILabel lblLatitude = getElementFactory().getLabel(By.id("latitude"), "Latitude"); - private final ILabel lblLongitude = getElementFactory().getLabel(By.id("longitude"), "Longitude"); - private final IButton btnConsent = getElementFactory().getButton(By.xpath("//button[@aria-label='Consent']"), "Consent"); + private final ILabel lblLatitude = getElementFactory().getLabel(By.xpath("//*[@id='latitude'] | (//td[contains(text(), 'Latitude')]/following-sibling::td)[1]"), "Latitude"); + private final ILabel lblLongitude = getElementFactory().getLabel(By.xpath("//*[@id='longitude'] | (//td[contains(text(), 'Longitude')]/following-sibling::td)[1]"), "Longitude"); + private final IButton btnConsent = getElementFactory().getButton(By.xpath("//button[@aria-label='Consent' or contains(@class,'fc-cta-consent')]"), "Consent"); public MyLocationForm() { - super(By.xpath("//h1[contains(text(),'My Location')]"), "My Location"); + super(By.xpath("//*[contains(text(),'Location')]"), "My Location"); } public double getLatitude() { diff --git a/src/test/java/tests/usecases/devtools/DeviceEmulationTest.java b/src/test/java/tests/usecases/devtools/DeviceEmulationTest.java index 6c68c44..d2a9311 100644 --- a/src/test/java/tests/usecases/devtools/DeviceEmulationTest.java +++ b/src/test/java/tests/usecases/devtools/DeviceEmulationTest.java @@ -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.v141.emulation.Emulation; -import org.openqa.selenium.devtools.v141.emulation.model.DisplayFeature; +import org.openqa.selenium.devtools.v142.emulation.Emulation; +import org.openqa.selenium.devtools.v142.emulation.model.DisplayFeature; import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; diff --git a/src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java b/src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java index 582e742..afcd46f 100644 --- a/src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java +++ b/src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java @@ -1,13 +1,19 @@ package tests.usecases.devtools; import aquality.selenium.browser.AqualityServices; +import aquality.selenium.browser.devtools.NetworkHandling; import org.openqa.selenium.TimeoutException; -import org.openqa.selenium.devtools.v141.network.model.ConnectionType; +import org.openqa.selenium.devtools.v143.network.model.ConnectionType; +import org.openqa.selenium.devtools.v143.network.model.NetworkConditions; import org.testng.Assert; import org.testng.annotations.Test; import tests.BaseTest; import theinternet.forms.WelcomeForm; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + public class NetworkSpeedEmulationTest extends BaseTest { private static final int DOWNLOAD_THROUGHPUT = 53; @@ -16,21 +22,37 @@ public class NetworkSpeedEmulationTest extends BaseTest { private static final int UPLOAD_THROUGHPUT_BIG = 270000; private static final int LATENCY = 27; + private final WelcomeForm welcomeForm = new WelcomeForm(); + + private NetworkHandling network() { + return getBrowser().devTools().network(); + } + + private List 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())); + } + private List getNetworkConditions(int downloadThroughput, int uploadThroughput) { + return Collections.singletonList(new NetworkConditions(welcomeForm.getUrl(), LATENCY, downloadThroughput, uploadThroughput, + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty())); + } + @Test public void networkSpeedEmulationTest() { getBrowser().setPageLoadTimeout(AqualityServices.getConfiguration().getTimeoutConfiguration().getScript()); - WelcomeForm welcomeForm = new WelcomeForm(); getBrowser().goTo(welcomeForm.getUrl()); Assert.assertTrue(welcomeForm.state().waitForDisplayed(), "Form must be opened"); boolean isOffline = true; - getBrowser().devTools().network().emulateConditions(isOffline, LATENCY, -1, -1); + network().emulateConditionsByRule(isOffline, getNetworkConditions(-1, -1)); + network().overrideState(isOffline, LATENCY, -1, -1); getBrowser().refresh(); getBrowser().waitForPageToLoad(); Assert.assertFalse(welcomeForm.state().isDisplayed(), "Form must not be opened when offline"); isOffline = false; - getBrowser().devTools().network().emulateConditions(isOffline, LATENCY, DOWNLOAD_THROUGHPUT, UPLOAD_THROUGHPUT, ConnectionType.BLUETOOTH.toString()); + network().emulateConditionsByRule(isOffline, getNetworkConditions(DOWNLOAD_THROUGHPUT, UPLOAD_THROUGHPUT, ConnectionType.BLUETOOTH)); + network().overrideState(isOffline, LATENCY, DOWNLOAD_THROUGHPUT, UPLOAD_THROUGHPUT, ConnectionType.BLUETOOTH); Assert.assertThrows(TimeoutException.class, () -> getBrowser().refresh()); - getBrowser().devTools().network().emulateConditions(isOffline, LATENCY, DOWNLOAD_THROUGHPUT_BIG, UPLOAD_THROUGHPUT_BIG, ConnectionType.CELLULAR4G.toString()); + network().emulateConditionsByRule(isOffline, getNetworkConditions(DOWNLOAD_THROUGHPUT_BIG, UPLOAD_THROUGHPUT_BIG, ConnectionType.CELLULAR4G)); getBrowser().refresh(); Assert.assertTrue(welcomeForm.state().waitForDisplayed(), "Form must be opened when online with good speed"); } diff --git a/src/test/java/tests/usecases/devtools/OverrideGeolocationTest.java b/src/test/java/tests/usecases/devtools/OverrideGeolocationTest.java index c878eb2..e3f012a 100644 --- a/src/test/java/tests/usecases/devtools/OverrideGeolocationTest.java +++ b/src/test/java/tests/usecases/devtools/OverrideGeolocationTest.java @@ -10,8 +10,8 @@ public class OverrideGeolocationTest extends BaseTest { - private static final double LAT_FOR_OVERRIDE = 53.90772672521578; - private static final double LNG_FOR_OVERRIDE = 27.458060411865375; + private static final double LAT_FOR_OVERRIDE = 53.907727; + private static final double LNG_FOR_OVERRIDE = 27.458060; @Test public void overrideGeolocationTest() { diff --git a/src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java b/src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java index 26c13d6..c063939 100644 --- a/src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java +++ b/src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java @@ -8,7 +8,7 @@ import manytools.BrowserLanguageForm; import manytools.UserAgentForm; import org.openqa.selenium.devtools.idealized.Network; -import org.openqa.selenium.devtools.v141.emulation.Emulation; +import org.openqa.selenium.devtools.v142.emulation.Emulation; import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; diff --git a/src/test/java/w3schools/forms/SelectMultipleForm.java b/src/test/java/w3schools/forms/SelectMultipleForm.java index bf401d3..f533c7e 100644 --- a/src/test/java/w3schools/forms/SelectMultipleForm.java +++ b/src/test/java/w3schools/forms/SelectMultipleForm.java @@ -3,6 +3,7 @@ import aquality.selenium.browser.AqualityServices; import aquality.selenium.core.logging.Logger; import aquality.selenium.elements.interfaces.IButton; +import aquality.selenium.elements.interfaces.ILabel; import aquality.selenium.elements.interfaces.IMultiChoiceBox; import aquality.selenium.elements.interfaces.ITextBox; import aquality.selenium.forms.Form; @@ -17,24 +18,30 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; +import static aquality.selenium.browser.AqualityServices.getBrowser; import static aquality.selenium.browser.AqualityServices.getConfiguration; public class SelectMultipleForm extends Form { private final IMultiChoiceBox cbxCars = getElementFactory().getMultiChoiceBox(By.id("cars"), "Cars"); - private final IButton btnSubmit = getElementFactory().getButton(By.cssSelector("input[type='submit']"), "Submit"); + private final IButton btnSubmit = getElementFactory().getButton(By.cssSelector("input[type=submit]"), "Submit"); private final ITextBox txbResult = getElementFactory().getTextBox(By.cssSelector(".w3-large"), "Result"); - private final IButton btnAcceptCookies = getElementFactory().getButton(By.id("accept-choices"), "Accept cookies"); + private final IButton btnAcceptCookies = getElementFactory().getButton(By.cssSelector("span.fast-cmp-home-accept button"), "Accept cookies"); + private final ILabel frameCmpContainer = getElementFactory().getLabel(By.id("fast-cmp-iframe"), "Cookies iframe"); public SelectMultipleForm() { super(By.id("iframe"), "Select Multiple"); } public void acceptCookies() { + if (frameCmpContainer.state().waitForExist()) { + getBrowser().getDriver().switchTo().frame(frameCmpContainer.getElement()); + } if (btnAcceptCookies.state().waitForDisplayed(getConfiguration().getTimeoutConfiguration().getScript())) { btnAcceptCookies.click(); - btnAcceptCookies.state().waitForNotDisplayed(); } + getBrowser().getDriver().switchTo().defaultContent(); + frameCmpContainer.state().waitForNotDisplayed(); } public void switchToResultFrame() {