From 2847889ac3f00dc2634bf4ebb1a7da9957a0378d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alaksiej=20Miale=C5=A1ka?= Date: Wed, 11 Nov 2020 13:29:14 +0200 Subject: [PATCH] Update WebDriverManager reference to enable "MatchingBrowser" webDriverVersion strategy (#194) * Update WebDriverManager reference to enable "MatchingBrowser" webDriverVersion strategy * Stabilize JS Focus test, replace obsolete property with State reference in tests * Fix ParallelScope in LocalizationManagerTests --- .../src/Aquality.Selenium/Aquality.Selenium.csproj | 4 ++-- .../src/Aquality.Selenium/Browsers/LocalBrowserFactory.cs | 3 ++- .../src/Aquality.Selenium/Resources/settings.json | 2 +- .../Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj | 4 ++-- .../Integration/Actions/JsActionsTests.cs | 5 +++-- .../Integration/Actions/MouseActionsTests.cs | 2 +- .../Aquality.Selenium.Tests/Integration/ElementStateTests.cs | 2 +- .../TestApp/AutomationPractice/Forms/ProductListForm.cs | 1 + .../Integration/Usecases/CustomBrowserFactoryTests.cs | 1 + .../Integration/Usecases/ShoppingCartTests.cs | 4 ++-- .../Aquality.Selenium.Tests/Resources/settings.azure.json | 2 +- .../tests/Aquality.Selenium.Tests/Resources/settings.json | 2 +- .../Aquality.Selenium.Tests/Unit/LocalizationManagerTests.cs | 2 +- 13 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj index de963765..a541d2ad 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj +++ b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj @@ -68,9 +68,9 @@ - + - + diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/LocalBrowserFactory.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/LocalBrowserFactory.cs index 5863f461..9cb8f55c 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/LocalBrowserFactory.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/LocalBrowserFactory.cs @@ -87,7 +87,8 @@ private RemoteWebDriver GetDriver(DriverService driverService, DriverOptions private static void SetUpDriver(IDriverConfig driverConfig, IDriverSettings driverSettings) { var architecture = driverSettings.SystemArchitecture.Equals(Architecture.Auto) ? ArchitectureHelper.GetArchitecture() : driverSettings.SystemArchitecture; - var version = driverSettings.WebDriverVersion.Equals("Latest") ? driverConfig.GetLatestVersion() : driverSettings.WebDriverVersion; + var version = driverSettings.WebDriverVersion.Equals(VersionResolveStrategy.Latest) ? driverConfig.GetLatestVersion() : driverSettings.WebDriverVersion; + version = version.Equals(VersionResolveStrategy.MatchingBrowser) ? driverConfig.GetMatchingBrowserVersion() : version; var url = UrlHelper.BuildUrl(architecture.Equals(Architecture.X32) ? driverConfig.GetUrl32() : driverConfig.GetUrl64(), version); var binaryPath = FileHelper.GetBinDestination(driverConfig.GetName(), version, architecture, driverConfig.GetBinaryName()); if (!File.Exists(binaryPath) || !Environment.GetEnvironmentVariable("PATH").Contains(binaryPath)) diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/settings.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/settings.json index 7c78e7c3..4d07a6b7 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Resources/settings.json +++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/settings.json @@ -6,7 +6,7 @@ "driverSettings": { "chrome": { - "webDriverVersion": "Latest", + "webDriverVersion": "MatchingBrowser", "capabilities": { "enableVNC": true, "loggingPrefs": { 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 c0304843..b34ab07a 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj @@ -26,11 +26,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs index b8f8dde7..e1f9d586 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs @@ -21,7 +21,7 @@ public void Should_BePossibleTo_Click() var welcomeForm = new WelcomeForm(); welcomeForm.Open(); welcomeForm.GetExampleLink(AvailableExample.Dropdown).JsActions.Click(); - Assert.IsTrue(new DropdownForm().IsDisplayed, "Dropdown form should be displayed"); + Assert.IsTrue(new DropdownForm().State.WaitForDisplayed(), "Dropdown form should be displayed"); } [Test] @@ -30,7 +30,7 @@ public void Should_BePossibleTo_ClickAndWait() var welcomeForm = new WelcomeForm(); welcomeForm.Open(); welcomeForm.GetExampleLink(AvailableExample.Dropdown).JsActions.ClickAndWait(); - Assert.IsTrue(new DropdownForm().IsDisplayed, "Dropdown form should be displayed"); + Assert.IsTrue(new DropdownForm().State.WaitForDisplayed(), "Dropdown form should be displayed"); } [Test] @@ -69,6 +69,7 @@ public void Should_BePossibleTo_SetFocus() var expectedText = currentText.Remove(currentText.Length - 1); product.TxtQuantity.JsActions.SetFocus(); product.TxtQuantity.SendKeys(Keys.Delete); + product.TxtQuantity.SendKeys(Keys.Backspace); Assert.AreEqual(expectedText, product.TxtQuantity.Value, $"One character should be removed from '{currentText}'"); } 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 0c72ca89..c80936ff 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs @@ -14,7 +14,7 @@ public void Should_BePossibleTo_Click() var welcomeForm = new WelcomeForm(); welcomeForm.Open(); welcomeForm.GetExampleLink(AvailableExample.Dropdown).MouseActions.Click(); - Assert.IsTrue(new DropdownForm().IsDisplayed, "Dropdown form should be displayed"); + Assert.IsTrue(new DropdownForm().State.WaitForDisplayed(), "Dropdown form should be displayed"); } [Test] diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ElementStateTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ElementStateTests.cs index ee289589..12902939 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ElementStateTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ElementStateTests.cs @@ -55,7 +55,7 @@ public void Should_BePossibleTo_CheckElementIsClickableState() [Test] public void Should_BePossibleTo_WaitForElementEnabledState() { - Assert.IsTrue(dynamicControlsForm.IsDisplayed, "Form 'Dynamic Controls' should be displayed"); + Assert.IsTrue(dynamicControlsForm.State.WaitForDisplayed(), "Form 'Dynamic Controls' should be displayed"); dynamicControlsForm.ChangeInputStateButton.Click(); Assert.IsTrue(dynamicControlsForm.TextInputTextBox.State.WaitForEnabled(), "Text input should be enable after changing state"); dynamicControlsForm.ChangeInputStateButton.Click(); diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/AutomationPractice/Forms/ProductListForm.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/AutomationPractice/Forms/ProductListForm.cs index cfd376c5..1e5636d5 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/AutomationPractice/Forms/ProductListForm.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/AutomationPractice/Forms/ProductListForm.cs @@ -27,6 +27,7 @@ public ProductListForm() : base(By.XPath(FormLocator), "Product list") public void NavigateToLastProduct() { AqualityServices.Browser.GoTo(GetLastProduct().Href); + AqualityServices.Browser.WaitForPageToLoad(); } public ILink GetLastProduct() diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/CustomBrowserFactoryTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/CustomBrowserFactoryTests.cs index f07bc9ca..039faa18 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/CustomBrowserFactoryTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/CustomBrowserFactoryTests.cs @@ -68,6 +68,7 @@ private static void SetUpDriver(IDriverConfig driverConfig, IDriverSettings driv { var architecture = driverSettings.SystemArchitecture.Equals(Architecture.Auto) ? ArchitectureHelper.GetArchitecture() : driverSettings.SystemArchitecture; var version = driverSettings.WebDriverVersion.Equals("Latest") ? driverConfig.GetLatestVersion() : driverSettings.WebDriverVersion; + version = version.Equals(VersionResolveStrategy.MatchingBrowser) ? driverConfig.GetMatchingBrowserVersion() : version; var url = UrlHelper.BuildUrl(architecture.Equals(Architecture.X32) ? driverConfig.GetUrl32() : driverConfig.GetUrl64(), version); var binaryPath = FileHelper.GetBinDestination(driverConfig.GetName(), version, architecture, driverConfig.GetBinaryName()); if (!File.Exists(binaryPath) || !Environment.GetEnvironmentVariable("PATH").Contains(binaryPath)) diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/ShoppingCartTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/ShoppingCartTests.cs index c542d208..a55bba9e 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/ShoppingCartTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/ShoppingCartTests.cs @@ -30,7 +30,7 @@ public void BeforeTest() public void Should_BePossibleTo_PerformActions() { var sliderForm = new SliderForm(); - Assert.IsTrue(sliderForm.IsDisplayed, "Slider Form is not opened"); + Assert.IsTrue(sliderForm.State.WaitForDisplayed(), "Slider Form is not opened"); sliderForm.ClickNextButton(); sliderForm.ClickNextButton(); @@ -47,7 +47,7 @@ public void Should_BePossibleTo_PerformActions() shoppingCardSummaryForm.ClickProceedToCheckoutButton(); var authForm = new AuthenticationForm(); - Assert.IsTrue(authForm.IsDisplayed, "Authentication Form is not opened"); + Assert.IsTrue(authForm.State.WaitForDisplayed(), "Authentication Form is not opened"); var cartMenuForm = new CartMenuForm(); cartMenuForm.OpenCartMenu(); diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.azure.json b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.azure.json index 650c50f9..81abfbb2 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.azure.json +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.azure.json @@ -6,7 +6,7 @@ "driverSettings": { "chrome": { - "webDriverVersion": "83.0.4103.39", + "webDriverVersion": "MatchingBrowser", "capabilities": { "enableVNC": true }, diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.json b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.json index 6172faaa..ea41032b 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.json +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.json @@ -6,7 +6,7 @@ "driverSettings": { "chrome": { - "webDriverVersion": "Latest", + "webDriverVersion": "MatchingBrowser", "capabilities": { "enableVNC": true }, diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/LocalizationManagerTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/LocalizationManagerTests.cs index d19dcde8..b7384294 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/LocalizationManagerTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/LocalizationManagerTests.cs @@ -8,7 +8,7 @@ namespace Aquality.Selenium.Tests.Unit { [TestFixture] - [Parallelizable(ParallelScope.All)] + [Parallelizable(ParallelScope.Children)] internal class LocalizationManagerTests { private const string LocalizedNavigationMessage = "Navigate to url - 'test'";