From a69263ae9d9c64f0ff1005d7cdbf86ed35226e06 Mon Sep 17 00:00:00 2001 From: Aliaksej Mialeshka Date: Thu, 18 Jul 2024 19:42:06 +0200 Subject: [PATCH 1/4] Revert "Update Aquality.Selenium.csproj" This reverts commit 9d0641fd7896a9bc8a122c102a341d6abafcce19. --- .../src/Aquality.Selenium/Aquality.Selenium.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj index 146099d..3353361 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj +++ b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj @@ -86,7 +86,7 @@ - + From 77f925546a1a32505feba0be3640b537fa0a49da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alaksiej=20Miale=C5=A1ka?= Date: Mon, 22 Jul 2024 16:54:29 +0200 Subject: [PATCH 2/4] Implement native scroll actions +semver: feature (#258) - cover with tests - add localization values for scrolling actions --- .../Aquality.Selenium/Aquality.Selenium.xml | 32 +++++++++++++++++ .../src/Aquality.Selenium/Browsers/Browser.cs | 25 ++++++++++++++ .../Elements/Actions/JsActions.cs | 2 +- .../Elements/Actions/MouseActions.cs | 34 +++++++++++++++++++ .../src/Aquality.Selenium/Forms/Form.cs | 10 ++++++ .../Resources/Localization/be.json | 5 ++- .../Resources/Localization/en.json | 5 ++- .../Resources/Localization/pl.json | 5 ++- .../Resources/Localization/ru.json | 5 ++- .../Resources/Localization/uk.json | 5 ++- .../Integration/Actions/MouseActionsTests.cs | 33 ++++++++++++++++++ .../Integration/BrowserTests.cs | 16 +++++++++ 12 files changed, 171 insertions(+), 6 deletions(-) diff --git a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml index a60beb6..a88e454 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml +++ b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml @@ -230,6 +230,21 @@ Horizontal coordinate. Vertical coordinate. + + + Scrolls window by coordinates using JavaScript. + + Horizontal coordinate. + Vertical coordinate. + + + + Scrolls portion of screen from specified origin + + Origination point (either viewport or element, with possible offset). + Horizontal coordinate. + Vertical coordinate. + Executes JS script from embedded resource file (*.js). @@ -1452,6 +1467,16 @@ Perfroms right click on element. + + + Scrolling page to the element. + + + + + Scrolling page from an element. + + Moves mouse to the element. @@ -2424,6 +2449,13 @@ horizontal coordinate vertical coordinate + + + Scroll form via JavaScript without scrolling entire page + + horizontal coordinate + vertical coordinate + DevTools Command/Result logging options. diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs index 02fa0af..d9bb0da 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs @@ -10,6 +10,8 @@ using System.Collections.ObjectModel; using IDevTools = OpenQA.Selenium.DevTools.IDevTools; +using OpenQA.Selenium.Interactions; +using static OpenQA.Selenium.Interactions.WheelInputDevice; namespace Aquality.Selenium.Browsers { @@ -319,9 +321,32 @@ public ReadOnlyCollection GetLogs(string logKind) /// Vertical coordinate. public void ScrollWindowBy(int x, int y) { + Logger.Info("loc.scrolling.by", x, y); + new Actions(Driver).ScrollByAmount(x, y).Perform(); + } + + /// + /// Scrolls window by coordinates using JavaScript. + /// + /// Horizontal coordinate. + /// Vertical coordinate. + public void ScrollWindowByViaJs(int x, int y) + { + Logger.Info("loc.scrolling.by.js", x, y); ExecuteScript(JavaScript.ScrollWindowBy, x, y); } + /// + /// Scrolls portion of screen from specified origin + /// + /// Origination point (either viewport or element, with possible offset). + /// Horizontal coordinate. + /// Vertical coordinate. + public void ScrollFromOrigin(ScrollOrigin scrollOrigin, int x, int y) + { + new Actions(Driver).ScrollFromOrigin(scrollOrigin, x, y).Perform(); + } + /// /// Executes JS script from embedded resource file (*.js). /// diff --git a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs index d598862..9692942 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs @@ -93,7 +93,7 @@ public void ScrollIntoView() /// Vertical coordinate public void ScrollBy(int x, int y) { - LogElementAction("loc.scrolling.js"); + LogElementAction("loc.scrolling.by.js", x, y); ExecuteScript(JavaScript.ScrollBy, x, y); } diff --git a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs index c1a0e96..3dd9415 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs @@ -6,6 +6,7 @@ using Aquality.Selenium.Core.Utilities; using Aquality.Selenium.Core.Localization; using Aquality.Selenium.Configurations; +using static OpenQA.Selenium.Interactions.WheelInputDevice; namespace Aquality.Selenium.Elements.Actions { @@ -57,6 +58,39 @@ public void RightClick() elementActionsRetrier.DoWithRetry(() => PerformAction(element => MoveToElement(element).ContextClick(element))); } + /// + /// Scrolling page to the element. + /// + public void ScrollToElement() + { + LogElementAction("loc.scrolling"); + elementActionsRetrier.DoWithRetry(() => PerformAction(element => new SeleniumActions(AqualityServices.Browser.Driver).ScrollToElement(element))); + } + + /// + /// Scrolling page from an element. + /// + public void ScrollFromOrigin(int x, int y, int? xOffset = null, int? yOffset = null) + { + LogElementAction("loc.scrolling.by", x, y); + elementActionsRetrier.DoWithRetry(() => + { + var scrollOrigin = new ScrollOrigin + { + Element = element.GetElement() + }; + if (xOffset != null) + { + scrollOrigin.XOffset = xOffset.Value; + } + if (yOffset != null) + { + scrollOrigin.YOffset = yOffset.Value; + } + AqualityServices.Browser.ScrollFromOrigin(scrollOrigin, x, y); + }); + } + /// /// Moves mouse to the element. /// diff --git a/Aquality.Selenium/src/Aquality.Selenium/Forms/Form.cs b/Aquality.Selenium/src/Aquality.Selenium/Forms/Form.cs index 0120ce8..9630231 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Forms/Form.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Forms/Form.cs @@ -86,6 +86,16 @@ protected Form(By locator, string name) /// horizontal coordinate /// vertical coordinate public void ScrollBy(int x, int y) + { + FormElement.MouseActions.ScrollFromOrigin(x, y); + } + + /// + /// Scroll form via JavaScript without scrolling entire page + /// + /// horizontal coordinate + /// vertical coordinate + public void ScrollByJs(int x, int y) { FormElement.JsActions.ScrollBy(x, y); } diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json index 90669f5..f7ba8b6 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json +++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json @@ -66,7 +66,10 @@ "loc.movingFrom": "Адводзім курсор мышы ад элемента", "loc.radio": "Радыёкнопка", "loc.scrolling.center.js": "Пракручваем старонку да цэнтра элемента праз JavaScript", - "loc.scrolling.js": "Пракручваем старонку праз JavaScript", + "loc.scrolling.js": "Пракручваем старонку да элемента праз JavaScript", + "loc.scrolling": "Пракручваем старонку да элемента", + "loc.scrolling.by": "Пракручваем на ({0},{1})", + "loc.scrolling.by.js": "Пракручваем на ({0},{1}) праз JavaScript", "loc.selecting.value": "Выбіраем значэнне - '{0}'", "loc.deselecting.value": "Адмяняем выбар значэння - '{0}'", "loc.send.text": "Задаем тэкст - '{0}'", diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json index 03b5483..c2fd571 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json +++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json @@ -66,7 +66,10 @@ "loc.movingFrom": "Moving mouse from element", "loc.radio": "RadioButton", "loc.scrolling.center.js": "Scrolling to the center via JavaScript", - "loc.scrolling.js": "Scrolling via JavaScript", + "loc.scrolling.js": "Scrolling to element via JavaScript", + "loc.scrolling": "Scrolling to element", + "loc.scrolling.by": "Scrolling by ({0},{1})", + "loc.scrolling.by.js": "Scrolling by ({0},{1}) via JavaScript", "loc.selecting.value": "Selecting value - '{0}'", "loc.deselecting.value": "Deselecting value - '{0}'", "loc.send.text": "Setting text - '{0}'", diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/pl.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/pl.json index 9f38336..163c398 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/pl.json +++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/pl.json @@ -66,7 +66,10 @@ "loc.movingFrom": "Przesuwanie myszy z elementu", "loc.radio": "RadioButton", "loc.scrolling.center.js": "Przewijanie do centrum przez JavaScript", - "loc.scrolling.js": "Przewijanie przez JavaScript", + "loc.scrolling.js": "Przewijanie do elementu przez JavaScript", + "loc.scrolling": "Przewijanie do elementu", + "loc.scrolling.by": "Przewijanie o ({0},{1})", + "loc.scrolling.by.js": "Przewijanie o ({0},{1}) przez JavaScript", "loc.selecting.value": "Wybieranie wartości - '{0}'", "loc.deselecting.value": "Anulowanie wybierania wartości - '{0}'", "loc.send.text": "Ustawianie tekstu - '{0}'", diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json index dd35bcf..c3c7d0e 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json +++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json @@ -66,7 +66,10 @@ "loc.movingFrom": "Сдвиг курсора с элемента", "loc.radio": "Радиокнопка", "loc.scrolling.center.js": "Скроллинг в центр посредством JavaScript", - "loc.scrolling.js": "Скроллинг с помощью JavaScript", + "loc.scrolling.js": "Скроллинг к элементу с помощью JavaScript", + "loc.scrolling": "Скроллинг к элементу", + "loc.scrolling.by": "Скроллинг на ({0},{1})", + "loc.scrolling.by.js": "Скроллинг на ({0},{1}) с помощью JavaScript", "loc.selecting.value": "Выбор значения - '{0}'", "loc.deselecting.value": "Отмена выбора значения - '{0}'", "loc.send.text": "Ввод текста - '{0}'", diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/uk.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/uk.json index d3850c9..3e4636b 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/uk.json +++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/uk.json @@ -66,7 +66,10 @@ "loc.movingFrom": "Переміщення миші від елемента", "loc.radio": "Радіокнопка", "loc.scrolling.center.js": "Прокрутка до центру за допомогою JavaScript", - "loc.scrolling.js": "Прокрутка за допомогою JavaScript", + "loc.scrolling.js": "Прокрутка до елемента за допомогою JavaScript", + "loc.scrolling": "Прокрутка до елемента", + "loc.scrolling.by": "Прокрутка на ({0},{1})", + "loc.scrolling.by.js": "Прокрутка на ({0},{1}) за допомогою JavaScript", "loc.selecting.value": "Вибір значення - '{0}'", "loc.deselecting.value": "Скасування выбору значення - '{0}'", "loc.send.text": "Встановлення тексту - '{0}'", diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs index 2bd2736..bd6ab98 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs @@ -42,5 +42,38 @@ public void Should_BePossibleTo_MoveToElement() JQueryMenuForm.EnabledButton.MouseActions.MoveToElement(); Assert.That(JQueryMenuForm.IsEnabledButtonFocused, "Element should be focused after move mouse"); } + + [Test] + public void Should_BePossibleTo_ScrollToElement() + { + var infiniteScrollForm = new InfiniteScrollForm(); + infiniteScrollForm.Open(); + infiniteScrollForm.WaitForPageToLoad(); + var size = infiniteScrollForm.LastExampleLabel.Visual.Size; + AqualityServices.Browser.SetWindowSize(size.Width, size.Height); + var defaultCount = infiniteScrollForm.ExampleLabels.Count; + Assert.DoesNotThrow( + () => AqualityServices.ConditionalWait.WaitForTrue(() => + { + infiniteScrollForm.LastExampleLabel.MouseActions.ScrollToElement(); + return infiniteScrollForm.ExampleLabels.Count > defaultCount; + }), "Some examples should be added after scroll"); + } + + [Test] + public void Should_BePossibleTo_ScrollFromOrigin() + { + var infiniteScrollForm = new InfiniteScrollForm(); + infiniteScrollForm.Open(); + infiniteScrollForm.WaitForPageToLoad(); + var defaultCount = infiniteScrollForm.ExampleLabels.Count; + Assert.DoesNotThrow( + () => AqualityServices.ConditionalWait.WaitForTrue(() => + { + var formHeight = infiniteScrollForm.Size.Height; + infiniteScrollForm.LastExampleLabel.MouseActions.ScrollFromOrigin(0, formHeight); + return infiniteScrollForm.ExampleLabels.Count > defaultCount; + }), "Some examples should be added after scroll"); + } } } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs index 5b9bc6f..0e11466 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs @@ -200,6 +200,22 @@ public void Should_BePossibleTo_ScrollWindowBy() }), "Some examples should be added after scroll"); } + [Test] + public void Should_BePossibleTo_ScrollWindowBy_ViaJs() + { + var infiniteScrollForm = new InfiniteScrollForm(); + infiniteScrollForm.Open(); + infiniteScrollForm.WaitForPageToLoad(); + var defaultCount = infiniteScrollForm.ExampleLabels.Count; + Assert.DoesNotThrow( + () => AqualityServices.ConditionalWait.WaitForTrue(() => + { + var formHeight = infiniteScrollForm.Size.Height; + AqualityServices.Browser.ScrollWindowByViaJs(0, formHeight); + return infiniteScrollForm.ExampleLabels.Count > defaultCount; + }), "Some examples should be added after scroll"); + } + [Test] public void Should_BePossibleTo_GetBrowserName() { From 3dce5547e8f17d8d1fd708c66c61895aab0da6aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alaksiej=20Miale=C5=A1ka?= Date: Mon, 29 Jul 2024 20:59:36 +0200 Subject: [PATCH 3/4] Update Selenium version to 4.23.0 (#259) * Update Selenium version to 4.23.0 +semver:feature - Add async methods to BrowserNavigation proxy * Update the pipeline, add missed BackAsync implementation --- .../Aquality.Selenium.csproj | 2 +- .../Aquality.Selenium/Aquality.Selenium.xml | 28 +++++++++- .../Browsers/BrowserNavigation.cs | 53 +++++++++++++++++++ .../Browsers/BrowserWindowNavigation.cs | 1 - .../WebDriverSettings/FirefoxSettings.cs | 4 +- .../Elements/Actions/MouseActions.cs | 2 +- .../src/Aquality.Selenium/Elements/Element.cs | 1 - .../Aquality.Selenium.Tests.csproj | 2 +- .../Integration/DevToolsEmulationTests.cs | 6 +-- .../Usecases/FileDownloadingTests.cs | 1 - azure-pipelines.yml | 11 ++-- 11 files changed, 96 insertions(+), 15 deletions(-) diff --git a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj index 3353361..e2885d9 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj +++ b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj @@ -86,7 +86,7 @@ - + diff --git a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml index a88e454..ef1caaa 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml +++ b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml @@ -354,6 +354,12 @@ Navigates forward. + + + Move a single "item" forward in the browser's history as an asynchronous task. + + A task object representing the asynchronous operation. + Navigates to desired url. @@ -366,11 +372,31 @@ Uri representation of URL. + + + Navigate to a url as an asynchronous task. + + Uri object of where you want the browser to go. + A task object representing the asynchronous operation. + + + + Navigate to a url as an asynchronous task. + + Uri object of where you want the browser to go. + A task object representing the asynchronous operation. + Refreshes current page. + + + Reload the current page as an asynchronous task. + + A task object representing the asynchronous operation. + Registers authentication handler and awaits to start network monitoring. @@ -1464,7 +1490,7 @@ - Perfroms right click on element. + Performs right click on element. diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/BrowserNavigation.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/BrowserNavigation.cs index 98326a5..e1215ac 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/BrowserNavigation.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/BrowserNavigation.cs @@ -1,6 +1,7 @@ using Aquality.Selenium.Core.Localization; using OpenQA.Selenium; using System; +using System.Threading.Tasks; namespace Aquality.Selenium.Browsers { @@ -28,6 +29,16 @@ public void Back() driver.Navigate().Back(); } + /// + /// Move back a single entry in the browser's history as an asynchronous task. + /// + /// A task object representing the asynchronous operation. + public Task BackAsync() + { + Logger.Info("loc.browser.back"); + return driver.Navigate().BackAsync(); + } + /// /// Navigates forward. /// @@ -37,6 +48,16 @@ public void Forward() driver.Navigate().Forward(); } + /// + /// Move a single "item" forward in the browser's history as an asynchronous task. + /// + /// A task object representing the asynchronous operation. + public Task ForwardAsync() + { + Logger.Info("loc.browser.forward"); + return driver.Navigate().ForwardAsync(); + } + /// /// Navigates to desired url. /// @@ -77,6 +98,28 @@ public void GoToUrl(Uri url) } } + /// + /// Navigate to a url as an asynchronous task. + /// + /// String representation of where you want the browser to go. + /// A task object representing the asynchronous operation. + public Task GoToUrlAsync(string url) + { + InfoLocNavigate(url); + return driver.Navigate().GoToUrlAsync(url); + } + + /// + /// Navigate to a url as an asynchronous task. + /// + /// Uri object of where you want the browser to go. + /// A task object representing the asynchronous operation. + public Task GoToUrlAsync(Uri url) + { + InfoLocNavigate(url.ToString()); + return driver.Navigate().GoToUrlAsync(url); + } + /// /// Refreshes current page. /// @@ -86,6 +129,16 @@ public void Refresh() driver.Navigate().Refresh(); } + /// + /// Reload the current page as an asynchronous task. + /// + /// A task object representing the asynchronous operation. + public Task RefreshAsync() + { + Logger.Info("loc.browser.refresh"); + return driver.Navigate().RefreshAsync(); + } + private void InfoLocNavigate(string url) { Logger.Info("loc.browser.navigate", url); diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/BrowserWindowNavigation.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/BrowserWindowNavigation.cs index d68470b..ec7f40e 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/BrowserWindowNavigation.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/BrowserWindowNavigation.cs @@ -2,7 +2,6 @@ using OpenQA.Selenium; using System; using System.Collections.Generic; -using System.Linq; namespace Aquality.Selenium.Browsers { diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/FirefoxSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/FirefoxSettings.cs index d62a147..8eaaf7b 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/FirefoxSettings.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/FirefoxSettings.cs @@ -27,8 +27,8 @@ public FirefoxSettings(ISettingsFile settingsFile) : base(settingsFile) protected override IDictionary> KnownCapabilitySetters => new Dictionary> { - { "binary", (options, value) => ((FirefoxOptions) options).BrowserExecutableLocation = value.ToString() }, - { "firefox_binary", (options, value) => ((FirefoxOptions) options).BrowserExecutableLocation = value.ToString() }, + { "binary", (options, value) => ((FirefoxOptions) options).BinaryLocation = value.ToString() }, + { "firefox_binary", (options, value) => ((FirefoxOptions) options).BinaryLocation = value.ToString() }, { "firefox_profile", (options, value) => ((FirefoxOptions) options).Profile = new FirefoxProfileManager().GetProfile(value.ToString()) }, { "log", (options, value) => ((FirefoxOptions) options).LogLevel = value.ToEnum() } }; diff --git a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs index 3dd9415..75f739c 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs @@ -50,7 +50,7 @@ public void DoubleClick() } /// - /// Perfroms right click on element. + /// Performs right click on element. /// public void RightClick() { diff --git a/Aquality.Selenium/src/Aquality.Selenium/Elements/Element.cs b/Aquality.Selenium/src/Aquality.Selenium/Elements/Element.cs index d77af92..4cd8e08 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Elements/Element.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Elements/Element.cs @@ -16,7 +16,6 @@ using ICoreElementFactory = Aquality.Selenium.Core.Elements.Interfaces.IElementFactory; using ICoreElementFinder = Aquality.Selenium.Core.Elements.Interfaces.IElementFinder; using ICoreElementStateProvider = Aquality.Selenium.Core.Elements.Interfaces.IElementStateProvider; -using System.Collections.Generic; namespace Aquality.Selenium.Elements { diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj index cea9b59..3dc4b11 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj @@ -30,7 +30,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs index cad43bd..0aaf740 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs @@ -59,11 +59,11 @@ public void Should_BePossibleTo_SetAndClearDeviceMetricsOverride_WithVersionSpec { void setAction(long width, long height, bool isMobile, double scaleFactor) { - var parameters = new OpenQA.Selenium.DevTools.V125.Emulation.SetDeviceMetricsOverrideCommandSettings + var parameters = new OpenQA.Selenium.DevTools.V127.Emulation.SetDeviceMetricsOverrideCommandSettings { - DisplayFeature = new OpenQA.Selenium.DevTools.V125.Emulation.DisplayFeature + DisplayFeature = new OpenQA.Selenium.DevTools.V127.Emulation.DisplayFeature { - Orientation = OpenQA.Selenium.DevTools.V125.Emulation.DisplayFeatureOrientationValues.Horizontal + Orientation = OpenQA.Selenium.DevTools.V127.Emulation.DisplayFeatureOrientationValues.Horizontal }, Width = width, Height = height, diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/FileDownloadingTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/FileDownloadingTests.cs index 303212c..d26d4e4 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/FileDownloadingTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/FileDownloadingTests.cs @@ -4,7 +4,6 @@ using NUnit.Framework; using OpenQA.Selenium; using System; -using System.Collections.Generic; namespace Aquality.Selenium.Tests.Integration.Usecases { diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 536a6b6..38ce301 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -15,11 +15,12 @@ stages: displayName: Analyse code with SonarQube steps: - - task: SonarCloudPrepare@1 + - task: SonarCloudPrepare@2 displayName: 'Prepare SonarCloud analysis' inputs: SonarCloud: 'SonarCloud' organization: 'aqualityautomation' + scannerMode: 'MSBuild' projectKey: 'aquality-automation_aquality-selenium-dotnet' projectName: 'aquality-selenium-dotnet' projectVersion: '$(Build.BuildNumber)' @@ -35,12 +36,16 @@ stages: projects: Aquality.Selenium/Aquality.Selenium.sln arguments: -c $(buildConfiguration) - - task: SonarCloudAnalyze@1 + - task: SonarCloudAnalyze@2 displayName: 'Run SonarCloud code analysis' continueOnError: true + inputs: + jdkversion: 'JAVA_HOME_17_X64' - - task: SonarCloudPublish@1 + - task: SonarCloudPublish@2 displayName: 'Publish SonarCloud quality gate results' + inputs: + pollingTimeoutSec: '300' - job: tests displayName: Run tests From f9669bb94f6c99c6a59a23fee4ae3c4589e4c532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alaksiej=20Miale=C5=A1ka?= Date: Mon, 2 Sep 2024 17:02:18 +0200 Subject: [PATCH 4/4] Update to use Selenium 4.24.0 (#261) +semver:feature * Update to use Selenium 4.24.0 +semver:feature Use System.Text.Json instead of Newtonsoft.Json for DevToolsHandlong Update tests, use --disable-search-engine-choice-screen in tests Add Clear method to ITextBox interface Use new FindElements logic from Aquality.Selenium.Core to avoid possible StaleElementReference while iterating WebElements list to fix #260 --- .../Aquality.Selenium.csproj | 2 +- .../Aquality.Selenium/Aquality.Selenium.xml | 25 +++++++++---- .../Browsers/DevToolsHandling.cs | 36 +++++++++++-------- .../Browsers/DevToolsPerformanceExtensions.cs | 12 +++---- .../Browsers/JavaScriptHandling.cs | 2 +- .../Browsers/NetworkHandling.cs | 2 +- .../WebDriverSettings/DriverSettings.cs | 10 +++--- .../Elements/Actions/JsActions.cs | 4 +-- .../Elements/Actions/MouseActions.cs | 2 +- .../src/Aquality.Selenium/Elements/Element.cs | 2 +- .../Elements/Interfaces/ITextBox.cs | 5 +++ .../src/Aquality.Selenium/Elements/TextBox.cs | 7 ++++ .../Aquality.Selenium.Tests.csproj | 4 +-- .../Integration/DevToolsEmulationTests.cs | 6 ++-- .../Integration/DevToolsPerformanceTests.cs | 4 +-- .../Integration/Elements/TextBoxTests.cs | 27 ++++++++++++++ .../Resources/settings.json | 2 +- 17 files changed, 104 insertions(+), 48 deletions(-) diff --git a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj index e2885d9..8ae7a48 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj +++ b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj @@ -86,7 +86,7 @@ - + diff --git a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml index ef1caaa..68584f4 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml +++ b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml @@ -349,6 +349,12 @@ Navigates back. + + + Move back a single entry in the browser's history as an asynchronous task. + + A task object representing the asynchronous operation. + Navigates forward. @@ -376,7 +382,7 @@ Navigate to a url as an asynchronous task. - Uri object of where you want the browser to go. + String representation of where you want the browser to go. A task object representing the asynchronous operation. @@ -636,17 +642,17 @@ Logging preferences. An object representing the result of the command, if applicable. - + Sends the specified command and returns the associated command response. The name of the command to send. - The parameters of the command as a JToken object. + The parameters of the command as a JsonNode object. A CancellationToken object to allow for cancellation of the command. The execution timeout of the command in milliseconds. to throw an exception if a response is not received; otherwise, . Logging preferences. - A JToken based on a command created with the specified command name and parameters. + A JsonNode based on a command created with the specified command name and parameters. @@ -657,7 +663,7 @@ The execution timeout of the command in milliseconds. to throw an exception if a response is not received; otherwise, . Logging preferences. - A JToken based on a command created with the specified command name and parameters. + A JsonNode based on a command created with the specified command name and parameters. @@ -665,14 +671,14 @@ For more information, see . - + Disable collecting and reporting metrics. Current instance of . A task for asynchronous command. - + Enable collecting and reporting metrics. @@ -2361,6 +2367,11 @@ String representation of element's value + + + Clear element text. + + Type text in an element. diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsHandling.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsHandling.cs index f8e2958..1ef5948 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsHandling.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsHandling.cs @@ -1,6 +1,5 @@ using Aquality.Selenium.Core.Localization; using Aquality.Selenium.Logging; -using Newtonsoft.Json.Linq; using OpenQA.Selenium; using OpenQA.Selenium.Chromium; using OpenQA.Selenium.DevTools; @@ -8,6 +7,8 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json; +using System.Text.Json.Nodes; using System.Threading; using System.Threading.Tasks; @@ -31,7 +32,7 @@ public DevToolsHandling(IDevTools devToolsProvider) wasDevToolsSessionClosed = false; } - private ILocalizedLogger Logger => AqualityServices.LocalizedLogger; + private static ILocalizedLogger Logger => AqualityServices.LocalizedLogger; /// /// Gets a value indicating whether a DevTools session is active. @@ -114,9 +115,9 @@ public object ExecuteCdpCommand(string commandName, Dictionary c { if (devToolsProvider is ChromiumDriver driver) { - LogCommand(commandName, JToken.FromObject(commandParameters), loggingOptions); + LogCommand(commandName, JsonSerializer.SerializeToNode(commandParameters), loggingOptions); var result = driver.ExecuteCdpCommand(commandName, commandParameters); - var formattedResult = JToken.FromObject(result); + var formattedResult = JsonSerializer.SerializeToNode(result); LogCommandResult(formattedResult, loggingOptions); return result; } @@ -130,17 +131,17 @@ public object ExecuteCdpCommand(string commandName, Dictionary c /// Sends the specified command and returns the associated command response. /// /// The name of the command to send. - /// The parameters of the command as a JToken object. + /// The parameters of the command as a JsonNode object. /// A CancellationToken object to allow for cancellation of the command. /// The execution timeout of the command in milliseconds. /// to throw an exception if a response is not received; otherwise, . /// Logging preferences. - /// A JToken based on a command created with the specified command name and parameters. - public async Task SendCommand(string commandName, JToken commandParameters = null, + /// A JsonNode based on a command created with the specified command name and parameters. + public async Task SendCommand(string commandName, JsonNode commandParameters = null, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true, DevToolsCommandLoggingOptions loggingOptions = null) { - var parameters = commandParameters ?? new JObject(); + var parameters = commandParameters ?? new JsonObject(); LogCommand(commandName, parameters, loggingOptions); var result = await devToolsProvider.GetDevToolsSession() .SendCommand(commandName, parameters, cancellationToken, millisecondsTimeout, throwExceptionIfResponseNotReceived); @@ -156,23 +157,23 @@ public async Task SendCommand(string commandName, JToken commandParamete /// The execution timeout of the command in milliseconds. /// to throw an exception if a response is not received; otherwise, . /// Logging preferences. - /// A JToken based on a command created with the specified command name and parameters. - public async Task SendCommand(ICommand commandWithParameters, + /// A JsonNode based on a command created with the specified command name and parameters. + public async Task SendCommand(ICommand commandWithParameters, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true, DevToolsCommandLoggingOptions loggingOptions = null) { - return await SendCommand(commandWithParameters.CommandName, JToken.FromObject(commandWithParameters), + return await SendCommand(commandWithParameters.CommandName, JsonSerializer.SerializeToNode(commandWithParameters, commandWithParameters.GetType()), cancellationToken, millisecondsTimeout, throwExceptionIfResponseNotReceived, loggingOptions); } - private void LogCommand(string commandName, JToken commandParameters, DevToolsCommandLoggingOptions loggingOptions = null) + protected virtual void LogCommand(string commandName, JsonNode commandParameters, DevToolsCommandLoggingOptions loggingOptions = null) { var logging = (loggingOptions ?? new DevToolsCommandLoggingOptions()).Command; if (!logging.Enabled) { return; } - if (commandParameters.Any()) + if (IsNotEmpty(commandParameters)) { Logger.LogByLevel(logging.LogLevel, "loc.browser.devtools.command.execute.withparams", commandName, commandParameters.ToString()); } @@ -182,13 +183,18 @@ private void LogCommand(string commandName, JToken commandParameters, DevToolsCo } } - private void LogCommandResult(JToken result, DevToolsCommandLoggingOptions loggingOptions = null) + protected virtual void LogCommandResult(JsonNode result, DevToolsCommandLoggingOptions loggingOptions = null) { var logging = (loggingOptions ?? new DevToolsCommandLoggingOptions()).Result; - if (result.Any() && logging.Enabled) + if (IsNotEmpty(result) && logging.Enabled) { Logger.LogByLevel(logging.LogLevel, "loc.browser.devtools.command.execute.result", result.ToString()); } } + + private static bool IsNotEmpty(JsonNode jsonNode) + { + return jsonNode is JsonArray array ? array.Any() : (jsonNode as JsonObject).Any(); + } } } diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsPerformanceExtensions.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsPerformanceExtensions.cs index d926a2b..8a806ff 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsPerformanceExtensions.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsPerformanceExtensions.cs @@ -1,8 +1,8 @@ -using Newtonsoft.Json.Linq; -using OpenQA.Selenium.DevTools.V85.Performance; +using OpenQA.Selenium.DevTools.V85.Performance; using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; namespace Aquality.Selenium.Browsers @@ -18,7 +18,7 @@ public static class DevToolsPerformanceExtensions /// /// Current instance of . /// A task for asynchronous command. - public static async Task DisablePerfomanceMonitoring(this DevToolsHandling devTools) + public static async Task DisablePerformanceMonitoring(this DevToolsHandling devTools) { await devTools.SendCommand(new DisableCommandSettings()); } @@ -30,7 +30,7 @@ public static async Task DisablePerfomanceMonitoring(this DevToolsHandling devTo /// Time domain to use for collecting and reporting duration metrics. /// Allowed Values: timeTicks, threadTicks. /// A task for asynchronous command. - public static async Task EnablePerfomanceMonitoring(this DevToolsHandling devTools, string timeDomain = null) + public static async Task EnablePerformanceMonitoring(this DevToolsHandling devTools, string timeDomain = null) { await devTools.SendCommand(new EnableCommandSettings { TimeDomain = timeDomain }); } @@ -42,8 +42,8 @@ public static async Task EnablePerfomanceMonitoring(this DevToolsHandling devToo /// A task for asynchronous command with current values for run-time metrics as result. public static async Task> GetPerformanceMetrics(this DevToolsHandling devTools) { - JToken result = await devTools.SendCommand(new GetMetricsCommandSettings()); - return (result["metrics"] as JArray) + JsonNode result = await devTools.SendCommand(new GetMetricsCommandSettings()); + return (result["metrics"].AsArray()) .ToDictionary(item => item["name"].ToString(), item => double.Parse(item["value"].ToString(), CultureInfo.InvariantCulture)); } } diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/JavaScriptHandling.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/JavaScriptHandling.cs index 8e1512d..b362bb7 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/JavaScriptHandling.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/JavaScriptHandling.cs @@ -23,7 +23,7 @@ public JavaScriptHandling(IWebDriver driver) javaScriptEngine = new JavaScriptEngine(driver); } - private ILocalizedLogger Logger => AqualityServices.LocalizedLogger; + private static ILocalizedLogger Logger => AqualityServices.LocalizedLogger; /// /// Gets the read-only list of initialization scripts added for this JavaScript engine. diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/NetworkHandling.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/NetworkHandling.cs index 98840f3..cbe726d 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/NetworkHandling.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/NetworkHandling.cs @@ -21,7 +21,7 @@ public NetworkHandling(IWebDriver driver) network = driver.Manage().Network; } - private ILocalizedLogger Logger => AqualityServices.LocalizedLogger; + private static ILocalizedLogger Logger => AqualityServices.LocalizedLogger; /// /// A network request sent event. diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs index 420f948..67743ba 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs @@ -201,7 +201,7 @@ protected void SetOptionsByPropertyNames(DriverOptions options) } } - private void SetOptionByPropertyName(DriverOptions options, KeyValuePair option, Exception exception) + private static void SetOptionByPropertyName(DriverOptions options, KeyValuePair option, Exception exception) { var optionProperty = options .GetType() @@ -215,14 +215,14 @@ private void SetOptionByPropertyName(DriverOptions options, KeyValuePair AqualityServices.Browser; + private static Browser Browser => AqualityServices.Browser; - private IElementActionRetrier ActionRetrier => AqualityServices.Get(); + private static IElementActionRetrier ActionRetrier => AqualityServices.Get(); protected ILocalizedLogger Logger { get; } diff --git a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs index 75f739c..3229dee 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs @@ -113,7 +113,7 @@ public void MoveMouseFromElement() .MoveToElement(element, -element.Size.Width / 2, -element.Size.Height / 2))); } - private SeleniumActions MoveToElement(IWebElement element) + private static SeleniumActions MoveToElement(IWebElement element) { return new SeleniumActions(AqualityServices.Browser.Driver).MoveToElement(element); } diff --git a/Aquality.Selenium/src/Aquality.Selenium/Elements/Element.cs b/Aquality.Selenium/src/Aquality.Selenium/Elements/Element.cs index 4cd8e08..1715fb7 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Elements/Element.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Elements/Element.cs @@ -30,7 +30,7 @@ protected Element(By locator, string name, ElementState state) : base(locator, n public override ICoreElementStateProvider State => new ElementStateProvider(Locator, ConditionalWait, Finder, LogElementState); - protected IBrowserProfile BrowserProfile => AqualityServices.Get(); + protected virtual IBrowserProfile BrowserProfile => AqualityServices.Get(); public JsActions JsActions => new JsActions(this, ElementType, LocalizedLogger, BrowserProfile); diff --git a/Aquality.Selenium/src/Aquality.Selenium/Elements/Interfaces/ITextBox.cs b/Aquality.Selenium/src/Aquality.Selenium/Elements/Interfaces/ITextBox.cs index 89597e7..1c8b72a 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Elements/Interfaces/ITextBox.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Elements/Interfaces/ITextBox.cs @@ -11,6 +11,11 @@ public interface ITextBox : IElement /// String representation of element's value string Value { get; } + /// + /// Clear element text. + /// + void Clear(); + /// /// Type text in an element. /// diff --git a/Aquality.Selenium/src/Aquality.Selenium/Elements/TextBox.cs b/Aquality.Selenium/src/Aquality.Selenium/Elements/TextBox.cs index 3d23e05..a2c81a0 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Elements/TextBox.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Elements/TextBox.cs @@ -19,6 +19,13 @@ protected internal TextBox(By locator, string name, ElementState state) : base(l public string Value => GetAttribute(Attributes.Value); + public void Clear() + { + LogElementAction("loc.text.clearing"); + JsActions.HighlightElement(); + DoWithRetry(() => GetElement().Clear()); + } + public void Type(string value, bool secret = false) { LogElementAction("loc.text.typing", secret ? SecretMask : value); diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj index 3dc4b11..ecd0b4c 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj @@ -29,12 +29,12 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs index 0aaf740..fee2c29 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs @@ -59,11 +59,11 @@ public void Should_BePossibleTo_SetAndClearDeviceMetricsOverride_WithVersionSpec { void setAction(long width, long height, bool isMobile, double scaleFactor) { - var parameters = new OpenQA.Selenium.DevTools.V127.Emulation.SetDeviceMetricsOverrideCommandSettings + var parameters = new OpenQA.Selenium.DevTools.V128.Emulation.SetDeviceMetricsOverrideCommandSettings { - DisplayFeature = new OpenQA.Selenium.DevTools.V127.Emulation.DisplayFeature + DisplayFeature = new OpenQA.Selenium.DevTools.V128.Emulation.DisplayFeature { - Orientation = OpenQA.Selenium.DevTools.V127.Emulation.DisplayFeatureOrientationValues.Horizontal + Orientation = OpenQA.Selenium.DevTools.V128.Emulation.DisplayFeatureOrientationValues.Horizontal }, Width = width, Height = height, diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsPerformanceTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsPerformanceTests.cs index 2137542..25a61ea 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsPerformanceTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsPerformanceTests.cs @@ -11,7 +11,7 @@ internal class DevToolsPerformanceTests : UITest [Test] public void Should_BePossibleTo_CollectPerformanceMetrics() { - Assert.DoesNotThrowAsync(async () => await DevTools.EnablePerfomanceMonitoring(), "Should be possible to enable performance monitoring"); + Assert.DoesNotThrowAsync(async () => await DevTools.EnablePerformanceMonitoring(), "Should be possible to enable performance monitoring"); AqualityServices.Browser.GoTo("http://www.google.com"); IDictionary metrics = null; @@ -22,7 +22,7 @@ public void Should_BePossibleTo_CollectPerformanceMetrics() IDictionary otherMetrics = DevTools.GetPerformanceMetrics().GetAwaiter().GetResult(); Assert.That(otherMetrics, Is.Not.EqualTo(metrics), "Some additional metrics should have been collected"); - Assert.DoesNotThrowAsync(async () => await DevTools.DisablePerfomanceMonitoring(), "Should be possible to disable performance monitoring"); + Assert.DoesNotThrowAsync(async () => await DevTools.DisablePerformanceMonitoring(), "Should be possible to disable performance monitoring"); AqualityServices.Browser.Refresh(); metrics = DevTools.GetPerformanceMetrics().GetAwaiter().GetResult(); Assert.That(metrics, Is.Empty, "Metrics should have not been collected after performance monitoring have been disabled"); diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/TextBoxTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/TextBoxTests.cs index 8f1a5ef..104aaea 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/TextBoxTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/TextBoxTests.cs @@ -27,6 +27,33 @@ public void Should_BePossibleTo_FocusAndType() Assert.That(usernameTxb.Value, Is.EqualTo(text)); } + [Test] + public void Should_BePossibleTo_Clear_WhenWasEmpty() + { + var usernameTxb = authForm.UserNameTextBox; + usernameTxb.Clear(); + Assert.That(usernameTxb.Value, Is.Empty); + } + + [Test] + public void Should_BePossibleTo_Clear_WhenWasFilled() + { + var initialText = "initial value"; + var usernameTxb = authForm.UserNameTextBox; + usernameTxb.Type(initialText); + usernameTxb.Clear(); + Assert.That(usernameTxb.Value, Is.Empty); + } + + [Test] + public void Should_BePossibleTo_Clear_Twice() + { + var usernameTxb = authForm.UserNameTextBox; + usernameTxb.Clear(); + usernameTxb.Clear(); + Assert.That(usernameTxb.Value, Is.Empty); + } + [Test] public void Should_BePossibleTo_ClearAndType() { diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.json b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.json index 053ae45..794da47 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.json +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.json @@ -25,7 +25,7 @@ "Performance": "All" }, "excludedArguments": [ "enable-automation" ], - "startArguments": [], + "startArguments": [ "--disable-search-engine-choice-screen" ], "pageLoadStrategy": "Normal" }, "firefox": {