From 5b8a84c7c8ad406f7f7b046687e62639098497ae Mon Sep 17 00:00:00 2001 From: Aleksey Meleshko Date: Tue, 27 Oct 2026 20:28:00 +0100 Subject: [PATCH 1/5] Update to Selenium 4.50.0 +semver:feature - Ensure Element interfaces still use RemoteWebElement after migration to WebElement in aquality-selenium-core - Update dependency versions. - Update DevTools references to v154 (use 153 in custom version tests) - Reduce maven publication side by removing fat-jar assembly from regular build - Update central-publishing-maven-plugin version to 0.12.0 to fix publication error "Bundle has content that does NOT have a .pom file" --- pom.xml | 55 +++++++++++-------- .../browser/devtools/DevToolsHandling.java | 4 +- .../browser/devtools/EmulationHandling.java | 14 ++--- .../browser/devtools/JavaScriptHandling.java | 6 +- .../browser/devtools/NetworkHandling.java | 6 +- .../aquality/selenium/elements/Element.java | 2 +- .../elements/interfaces/IElement.java | 21 +++++++ .../devtools/DeviceEmulationTest.java | 4 +- .../devtools/NetworkSpeedEmulationTest.java | 4 +- .../devtools/OverrideUserAgentTest.java | 2 +- .../theinternet/forms/TheInternetForm.java | 7 --- .../java/theinternet/forms/WelcomeForm.java | 6 ++ 12 files changed, 81 insertions(+), 50 deletions(-) diff --git a/pom.xml b/pom.xml index 3e13879c..fd637da4 100644 --- a/pom.xml +++ b/pom.xml @@ -70,17 +70,17 @@ com.github.aquality-automation aquality-selenium-core - 4.19.0 + 5.0.2 org.apache.commons commons-lang3 - 3.20.0 + 3.21.0 com.fasterxml.jackson.core jackson-databind - 2.22.2 + 2.22.3 org.slf4j @@ -153,24 +153,6 @@ - - org.apache.maven.plugins - maven-assembly-plugin - 3.8.0 - - - - single - - package - - - jar-with-dependencies - - - - - org.apache.maven.plugins maven-source-plugin @@ -223,7 +205,7 @@ org.sonatype.central central-publishing-maven-plugin - 0.11.0 + 0.12.0 true central @@ -238,4 +220,33 @@ + + + + fatjar + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.8.0 + + + fat-jar + package + + single + + + + jar-with-dependencies + + + + + + + + + diff --git a/src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java b/src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java index 55e56c23..be41d990 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.v153.performance.Performance; -import org.openqa.selenium.devtools.v153.performance.model.Metric; +import org.openqa.selenium.devtools.v154.performance.Performance; +import org.openqa.selenium.devtools.v154.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 40e40a90..a6e73c9b 100644 --- a/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java +++ b/src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java @@ -2,13 +2,13 @@ import org.apache.commons.lang3.StringUtils; import org.openqa.selenium.devtools.Command; -import org.openqa.selenium.devtools.v153.dom.model.RGBA; -import org.openqa.selenium.devtools.v153.emulation.Emulation; -import org.openqa.selenium.devtools.v153.emulation.model.DevicePosture; -import org.openqa.selenium.devtools.v153.emulation.model.DisplayFeature; -import org.openqa.selenium.devtools.v153.emulation.model.MediaFeature; -import org.openqa.selenium.devtools.v153.emulation.model.ScreenOrientation; -import org.openqa.selenium.devtools.v153.page.model.Viewport; +import org.openqa.selenium.devtools.v154.dom.model.RGBA; +import org.openqa.selenium.devtools.v154.emulation.Emulation; +import org.openqa.selenium.devtools.v154.emulation.model.DevicePosture; +import org.openqa.selenium.devtools.v154.emulation.model.DisplayFeature; +import org.openqa.selenium.devtools.v154.emulation.model.MediaFeature; +import org.openqa.selenium.devtools.v154.emulation.model.ScreenOrientation; +import org.openqa.selenium.devtools.v154.page.model.Viewport; 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 37d9ecf5..cd4b4cfe 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.v153.page.Page; -import org.openqa.selenium.devtools.v153.page.model.ScriptIdentifier; -import org.openqa.selenium.devtools.v153.runtime.Runtime; +import org.openqa.selenium.devtools.v154.page.Page; +import org.openqa.selenium.devtools.v154.page.model.ScriptIdentifier; +import org.openqa.selenium.devtools.v154.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 813c9658..3afd30e5 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.v153.network.model.*; +import org.openqa.selenium.devtools.v154.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.v153.network.Network.*; +import static org.openqa.selenium.devtools.v154.network.Network.*; /** * DevTools commands for version-independent network interception. - * For more information, see {@link org.openqa.selenium.devtools.v153.network.Network} and {@link Network}. + * For more information, see {@link org.openqa.selenium.devtools.v154.network.Network} and {@link Network}. */ public class NetworkHandling { public static final String LOC_NETWORK_INTERCEPTOR_START = "loc.browser.network.interceptor.start"; diff --git a/src/main/java/aquality/selenium/elements/Element.java b/src/main/java/aquality/selenium/elements/Element.java index e0524bc0..129376e9 100644 --- a/src/main/java/aquality/selenium/elements/Element.java +++ b/src/main/java/aquality/selenium/elements/Element.java @@ -98,7 +98,7 @@ protected IConditionalWait getConditionalWait() { @Override public RemoteWebElement getElement(Duration timeout) { try { - return super.getElement(timeout); + return (RemoteWebElement) super.getElement(timeout); } catch (NoSuchElementException e) { getLogger().error(e.getMessage()); long timeoutInSeconds = timeout == null diff --git a/src/main/java/aquality/selenium/elements/interfaces/IElement.java b/src/main/java/aquality/selenium/elements/interfaces/IElement.java index d0fec8e6..4794239d 100644 --- a/src/main/java/aquality/selenium/elements/interfaces/IElement.java +++ b/src/main/java/aquality/selenium/elements/interfaces/IElement.java @@ -8,10 +8,31 @@ import aquality.selenium.elements.actions.MouseActions; import org.openqa.selenium.By; import org.openqa.selenium.Keys; +import org.openqa.selenium.remote.RemoteWebElement; +import java.time.Duration; import java.util.List; public interface IElement extends aquality.selenium.core.elements.interfaces.IElement, IShadowRootExpander { + /** + * Gets current element by specified {@link #getLocator()} + * Default timeout is provided in {@link aquality.selenium.core.configurations.ITimeoutConfiguration} + * {@link org.openqa.selenium.NoSuchElementException} throws if element not found + * + * @return instance of {@link RemoteWebElement} if found. + */ + default RemoteWebElement getElement() { + return getElement(null); + } + + /** + * Gets current element by specified {@link #getLocator()} + * {@link org.openqa.selenium.NoSuchElementException} throws if element not found + * + * @param timeout Timeout for waiting + * @return instance of {@link RemoteWebElement} if found. + */ + RemoteWebElement getElement(Duration timeout); /** * Send keys. diff --git a/src/test/java/tests/usecases/devtools/DeviceEmulationTest.java b/src/test/java/tests/usecases/devtools/DeviceEmulationTest.java index 7d1d2a57..3d1b3d34 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.v152.emulation.Emulation; -import org.openqa.selenium.devtools.v152.emulation.model.DisplayFeature; +import org.openqa.selenium.devtools.v153.emulation.Emulation; +import org.openqa.selenium.devtools.v153.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 cf2fee91..7a87bd2d 100644 --- a/src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java +++ b/src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java @@ -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.v153.network.model.ConnectionType; -import org.openqa.selenium.devtools.v153.network.model.NetworkConditions; +import org.openqa.selenium.devtools.v154.network.model.ConnectionType; +import org.openqa.selenium.devtools.v154.network.model.NetworkConditions; import org.testng.Assert; import org.testng.annotations.Test; import tests.BaseTest; diff --git a/src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java b/src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java index 70756d9a..5619a6ea 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.v152.emulation.Emulation; +import org.openqa.selenium.devtools.v153.emulation.Emulation; import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; diff --git a/src/test/java/theinternet/forms/TheInternetForm.java b/src/test/java/theinternet/forms/TheInternetForm.java index 67bb737f..280cf652 100644 --- a/src/test/java/theinternet/forms/TheInternetForm.java +++ b/src/test/java/theinternet/forms/TheInternetForm.java @@ -1,6 +1,5 @@ package theinternet.forms; -import aquality.selenium.elements.interfaces.ILink; import aquality.selenium.forms.Form; import org.openqa.selenium.By; @@ -11,15 +10,9 @@ public abstract class TheInternetForm extends Form { } private static final String THE_INTERNET_FORM_URL = "https://the-internet.herokuapp.com"; - private final ILink elementalSeleniumLink = getElementFactory().getLink(By.xpath("//a[contains(@href,'elementalselenium')]"), "Elemental Selenium"); - public String getUrl() { return THE_INTERNET_FORM_URL + getUri(); } - public void clickElementalSelenium() { - elementalSeleniumLink.click(); - } - protected abstract String getUri(); } diff --git a/src/test/java/theinternet/forms/WelcomeForm.java b/src/test/java/theinternet/forms/WelcomeForm.java index 7071af49..b2de53e6 100644 --- a/src/test/java/theinternet/forms/WelcomeForm.java +++ b/src/test/java/theinternet/forms/WelcomeForm.java @@ -10,6 +10,8 @@ public class WelcomeForm extends TheInternetForm { private static final String EXAMPLE_LINK_XPATH_TEMPLATE = "//a[contains(@href,'%s')]"; private final ILabel lblSubtitle = getElementFactory().getLabel(By.xpath("//h2"), "Sub title"); + private final ILink lnkElementalSelenium = getElementFactory().getLink(By.xpath("//a[contains(@href,'elementalselenium')]"), "Elemental Selenium"); + public WelcomeForm() { super(By.xpath("//h1[contains(.,'Welcome to the-internet')]"), "Welcome to the-internet"); } @@ -32,6 +34,10 @@ public Point getFormPointInViewPort(){ return getElementFactory().getLabel(getLocator(), getName()).getJsActions().getViewPortCoordinates(); } + public void clickElementalSelenium() { + lnkElementalSelenium.click(); + } + public enum AvailableExample { CHECKBOXES, DROPDOWN, From 3d6ac8bf96910de6f4231c1a289f3ee634427c1f Mon Sep 17 00:00:00 2001 From: Aleksey Meleshko Date: Tue, 27 Oct 2026 21:19:55 +0100 Subject: [PATCH 2/5] Stabilize the-internet website tests --- .../selenium/elements/interfaces/ByImage.java | 2 +- .../integration/elements/ElementTests.java | 2 +- src/test/resources/brokenImage.png | Bin 942 -> 1621 bytes 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/aquality/selenium/elements/interfaces/ByImage.java b/src/main/java/aquality/selenium/elements/interfaces/ByImage.java index 7a8af484..15b51792 100644 --- a/src/main/java/aquality/selenium/elements/interfaces/ByImage.java +++ b/src/main/java/aquality/selenium/elements/interfaces/ByImage.java @@ -169,7 +169,7 @@ protected Mat getScreenshot(SearchContext context) { : AqualityServices.getBrowser().getScreenshot(); boolean isBrowserScreenshot = context instanceof WebDriver || !(context instanceof TakesScreenshot); Mat source = Imgcodecs.imdecode(new MatOfByte(screenshotBytes), Imgcodecs.IMREAD_UNCHANGED); - long devicePixelRatio = (long) AqualityServices.getBrowser().executeScript(JavaScript.GET_DEVICE_PIXEL_RATIO); + double devicePixelRatio = (double) AqualityServices.getBrowser().executeScript(JavaScript.GET_DEVICE_PIXEL_RATIO); if (devicePixelRatio != 1 && isBrowserScreenshot) { int scaledWidth = (int) (source.width() / devicePixelRatio); int scaledHeight = (int) (source.height() / devicePixelRatio); diff --git a/src/test/java/tests/integration/elements/ElementTests.java b/src/test/java/tests/integration/elements/ElementTests.java index 1a1fba68..33cfcbb0 100644 --- a/src/test/java/tests/integration/elements/ElementTests.java +++ b/src/test/java/tests/integration/elements/ElementTests.java @@ -202,7 +202,7 @@ public void testShouldBePossibleToGetCssValue(){ ITextBox txbUsername = elementFactory.getTextBox(By.id("username"), "username"); String propertyName = "font-family"; - String expectedCssValue = "Helvetica"; + String expectedCssValue = "Arial"; Assert.assertTrue(txbUsername.getCssValue(propertyName).contains(expectedCssValue)); Assert.assertTrue(txbUsername.getCssValue(propertyName, HighlightState.HIGHLIGHT).contains(expectedCssValue)); diff --git a/src/test/resources/brokenImage.png b/src/test/resources/brokenImage.png index 89de85f62f1d7d59988899a69382cce97712c285..f48cbce157b4dd3119e04cd8aebad32c9689ff21 100644 GIT binary patch literal 1621 zcmeHI{X5eM03WxIQXS`LxOIIC%k|=hA@fpdHZ?3a&bTEeVruLO(_=;wtqsZh%uDk! zS)FEH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rK+mRXy%z4 zHzMrjum5Ps zt@HMr3)#*mdUN~TY|ojg=~tt8554$sQTS!r`QoF7X^HRnyKNx2H|Hx%ueIyIV?g zj-EBxWY)Fl=hFK5=kHd1sXOwqr(;WHEc@;HyLXE|96$GMuk{a>zrCkUUyjNSU3;n| z@zcNGtNow3JwB!M$?(tfcV}E@*9nBrn>%-J%}+1i^mX1>MRk>o4}M-gf1UqR`K~oL zR-Tu&tIv3TUTIUnh3m$G`EB!P$3c Date: Tue, 27 Oct 2026 21:45:17 +0100 Subject: [PATCH 3/5] Stabilize the-internet website tests --- .../selenium/elements/interfaces/ByImage.java | 7 ++++--- src/test/resources/brokenImage.png | Bin 1621 -> 942 bytes 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/aquality/selenium/elements/interfaces/ByImage.java b/src/main/java/aquality/selenium/elements/interfaces/ByImage.java index 15b51792..a2049672 100644 --- a/src/main/java/aquality/selenium/elements/interfaces/ByImage.java +++ b/src/main/java/aquality/selenium/elements/interfaces/ByImage.java @@ -169,10 +169,11 @@ protected Mat getScreenshot(SearchContext context) { : AqualityServices.getBrowser().getScreenshot(); boolean isBrowserScreenshot = context instanceof WebDriver || !(context instanceof TakesScreenshot); Mat source = Imgcodecs.imdecode(new MatOfByte(screenshotBytes), Imgcodecs.IMREAD_UNCHANGED); - double devicePixelRatio = (double) AqualityServices.getBrowser().executeScript(JavaScript.GET_DEVICE_PIXEL_RATIO); + double devicePixelRatio = + ((Number) AqualityServices.getBrowser().executeScript(JavaScript.GET_DEVICE_PIXEL_RATIO)).doubleValue(); if (devicePixelRatio != 1 && isBrowserScreenshot) { - int scaledWidth = (int) (source.width() / devicePixelRatio); - int scaledHeight = (int) (source.height() / devicePixelRatio); + double scaledWidth = source.width() / devicePixelRatio; + double scaledHeight = source.height() / devicePixelRatio; Imgproc.resize(source, source, new Size(scaledWidth, scaledHeight), 0, 0, Imgproc.INTER_AREA); } return source; diff --git a/src/test/resources/brokenImage.png b/src/test/resources/brok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(o!K`x4e+2k0ZHEal5Buv<=G8nvhojPnRZ6- zstq0>f%li*F~W>OZ0ZTx2wNwMQfkFGf17@2Xn^W*)5lk-^jnEL?jTbF+m;As@&N+lUo=4VL?lF;O9RJ3bKNg>{y4o{rc1*m1~Prx?SgMu!fXeSA?EP`Yg za<*BRTDT``A3%6H&R|^*xfyMctrAw=crcqp)rSyur}#?+w(|iIsM}WMQN1xyZgK8m zvM;^|8U05*P*r#H1PaHaaVFBdcP=Kpw0r4Gq2^@CO7Lp0`ireDDdyVTL>uC7mPwVq9F5t%8||6L;czfK z+GMwpW=_Q>H|bc+bw_)>$ixjIuRFEA+bg|YXTdWN}Oi*x+S3AT#8Ub%2fiFAmMpM%P#6*+ua^bjK%tm^p| z?B-i3h8#we6zy<19+91&8CP&KVY@LJFzpwBO=tpB_zaKn8 QZz} Date: Wed, 28 Oct 2026 18:54:48 +0100 Subject: [PATCH 4/5] Stabilize the-internet website tests --- src/test/java/tests/integration/ActionTests.java | 2 +- src/test/java/tests/integration/LocatorTests.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/java/tests/integration/ActionTests.java b/src/test/java/tests/integration/ActionTests.java index 50729004..740f4e47 100644 --- a/src/test/java/tests/integration/ActionTests.java +++ b/src/test/java/tests/integration/ActionTests.java @@ -32,7 +32,7 @@ public void testScrollToTheCenter() { final int accuracy = 1; WelcomeForm welcomeForm = new WelcomeForm(); getBrowser().goTo(welcomeForm.getUrl()); - ILink link = welcomeForm.getExampleLink(WelcomeForm.AvailableExample.HOVERS); + ILink link = welcomeForm.getExampleLink(WelcomeForm.AvailableExample.CHECKBOXES); link.getJsActions().scrollToTheCenter(); Long windowHeight = getScriptResultOrDefault("getWindowSize.js", 10L); diff --git a/src/test/java/tests/integration/LocatorTests.java b/src/test/java/tests/integration/LocatorTests.java index 4c07e727..77f76fda 100644 --- a/src/test/java/tests/integration/LocatorTests.java +++ b/src/test/java/tests/integration/LocatorTests.java @@ -1,6 +1,8 @@ package tests.integration; import aquality.selenium.browser.AqualityServices; +import aquality.selenium.core.elements.ElementState; +import aquality.selenium.core.elements.ElementsCount; import aquality.selenium.elements.interfaces.ByImage; import aquality.selenium.elements.interfaces.ILabel; import automationpractice.forms.ChallengingDomForm; @@ -43,7 +45,8 @@ public void testByImageLocator() { Assert.assertTrue(docLabels.size() > 1, "List of elements should be possible to find by image"); Assert.assertEquals(docLabels.size(), childLabels.size(), "Should be possible to find child elements by image with the same count"); - ILabel imgByTag = AqualityServices.getElementFactory().getLabel(By.tagName("img"), "img by tag"); + ILabel imgByTag = AqualityServices.getElementFactory() + .findElements(By.tagName("img"), "img by tag", ILabel.class, ElementsCount.MORE_THAN_ZERO, ElementState.DISPLAYED).get(1); float fullThreshold = 1; AtomicReference documentByImageContainer = new AtomicReference<>(); boolean isFound = AqualityServices.getConditionalWait().waitFor(browser -> { From e41f366eb389d7ab3b1c3e57cc4e5cd99ceab3c2 Mon Sep 17 00:00:00 2001 From: Aleksey Meleshko Date: Wed, 28 Oct 2026 19:31:19 +0100 Subject: [PATCH 5/5] Stabilize the-internet website tests --- .../tests/usecases/FileDownloadingTests.java | 2 +- .../theinternet/forms/FileDownloaderForm.java | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/test/java/tests/usecases/FileDownloadingTests.java b/src/test/java/tests/usecases/FileDownloadingTests.java index a18ae63f..f688af4e 100644 --- a/src/test/java/tests/usecases/FileDownloadingTests.java +++ b/src/test/java/tests/usecases/FileDownloadingTests.java @@ -32,7 +32,7 @@ public void testDownloading() { List tabs = new ArrayList<>(AqualityServices.getBrowser().getDriver().getWindowHandles()); AqualityServices.getBrowser().getDriver().switchTo().window(tabs.get(1)); - AqualityServices.getBrowser().goTo(TheInternetPage.DOWNLOAD.getAddress()); + downloaderForm.open(); downloaderForm.getLnkDownload(fileName).getJsActions().clickAndWait(); AqualityServices.getBrowser().getDriver().switchTo().window(tabs.get(0)); diff --git a/src/test/java/theinternet/forms/FileDownloaderForm.java b/src/test/java/theinternet/forms/FileDownloaderForm.java index 4609a857..9e7e7e2b 100644 --- a/src/test/java/theinternet/forms/FileDownloaderForm.java +++ b/src/test/java/theinternet/forms/FileDownloaderForm.java @@ -1,11 +1,19 @@ package theinternet.forms; +import aquality.selenium.browser.AlertActions; +import aquality.selenium.browser.AqualityServices; +import aquality.selenium.core.logging.Logger; import aquality.selenium.elements.interfaces.ILink; import aquality.selenium.forms.Form; import org.openqa.selenium.By; +import org.openqa.selenium.NoAlertPresentException; +import org.openqa.selenium.NoSuchWindowException; +import org.openqa.selenium.UnhandledAlertException; +import theinternet.TheInternetPage; public class FileDownloaderForm extends Form { private static final String DEFAULT_FILE_NAME = "some-file.txt"; + private static final int MAX_ALERTS_COUNT = 100; private static final String LINK_TEMPLATE = "//a[contains(@href,'%s')]"; public FileDownloaderForm() { @@ -20,4 +28,31 @@ public ILink getLnkDownload(String fileName) { public String getFileName() { return DEFAULT_FILE_NAME; } + + public void open() { + String url = TheInternetPage.DOWNLOAD.getAddress(); + try { + AqualityServices.getBrowser().goTo(url); + AqualityServices.getBrowser().waitForPageToLoad(); + } catch (UnhandledAlertException e) { + Logger.getInstance().debug("Unhandled alert detected", e); + for (int i = 0; i < MAX_ALERTS_COUNT; i++) + { + try + { + AqualityServices.getBrowser().handleAlert(AlertActions.ACCEPT); + } + catch (NoAlertPresentException noAlertPresentException) + { + Logger.getInstance().debug("No more alerts present", noAlertPresentException); + break; + } + } + if (!url.equals(AqualityServices.getBrowser().getCurrentUrl())) + { + throw new NoSuchWindowException(url + " was not opened", e); + } + AqualityServices.getBrowser().waitForPageToLoad(); + } + } }