diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/ChromeSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/ChromeSettings.cs index 9253d7ce..cf8e693c 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/ChromeSettings.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/ChromeSettings.cs @@ -30,11 +30,17 @@ public override DriverOptions DriverOptions SetChromePrefs(options); SetCapabilities(options, (name, value) => options.AddAdditionalOption(name, value)); SetChromeArguments(options); + SetChromeExcludedArguments(options); SetPageLoadStrategy(options); return options; } } + private void SetChromeExcludedArguments(ChromeOptions options) + { + options.AddExcludedArguments(BrowserExcludedArguments); + } + private void SetChromePrefs(ChromeOptions options) { foreach (var option in BrowserOptions) diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs index 239c9354..2e1c6dc5 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs @@ -18,6 +18,7 @@ public abstract class DriverSettings : IDriverSettings private IReadOnlyDictionary options; private IReadOnlyDictionary capabilities; private IReadOnlyList startArguments; + private IReadOnlyList excludedArguments; /// /// Instantiates class using JSON file with general settings. @@ -90,6 +91,23 @@ protected IReadOnlyDictionary BrowserOptions } } + protected IReadOnlyList BrowserExcludedArguments + { + get + { + if (excludedArguments == null) + { + excludedArguments = SettingsFile.GetValueListOrEmpty($"{DriverSettingsPath}.{nameof(excludedArguments)}"); + if (excludedArguments.Any()) + { + AqualityServices.LocalizedLogger.Debug("loc.browser.excludedArguments", args: string.Join(" ", excludedArguments)); + } + } + + return excludedArguments; + } + } + protected IReadOnlyList BrowserStartArguments { get @@ -97,12 +115,12 @@ protected IReadOnlyList BrowserStartArguments if (startArguments == null) { startArguments = SettingsFile.GetValueListOrEmpty($"{DriverSettingsPath}.{nameof(startArguments)}"); - if (startArguments.Any()) { AqualityServices.LocalizedLogger.Debug("loc.browser.arguments", args: string.Join(" ", startArguments)); } } + return startArguments; } } diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/EdgeSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/EdgeSettings.cs index 4db0caa6..80f4a131 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/EdgeSettings.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/EdgeSettings.cs @@ -30,11 +30,17 @@ public override DriverOptions DriverOptions SetEdgePrefs(options); SetCapabilities(options, (name, value) => options.AddAdditionalOption(name, value)); SetEdgeArguments(options); + SetEdgeExcludedArguments(options); SetPageLoadStrategy(options); return options; } } + private void SetEdgeExcludedArguments(EdgeOptions options) + { + options.AddExcludedArguments(BrowserExcludedArguments); + } + private void SetEdgePrefs(EdgeOptions options) { foreach (var option in BrowserOptions) diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/OperaSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/OperaSettings.cs index 05207a91..798e2cd8 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/OperaSettings.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/OperaSettings.cs @@ -31,11 +31,17 @@ public override DriverOptions DriverOptions SetOperaPrefs(options); SetCapabilities(options, (name, value) => options.AddAdditionalOption(name, value)); SetOperaArguments(options); + SetOperaExcludedArguments(options); SetPageLoadStrategy(options); return options; } } + private void SetOperaExcludedArguments(OperaOptions options) + { + options.AddExcludedArguments(BrowserExcludedArguments); + } + private void SetOperaPrefs(OperaOptions options) { foreach (var option in BrowserOptions) diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json index d27d8ae2..b5bed493 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json +++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json @@ -1,5 +1,6 @@ { "loc.browser.arguments": "Атрымалі стартавыя аргументы браўзэра з settings файла: {0}", + "loc.browser.excludedArguments": "Выключэнне аргументаў браўзэра з settings файла: {0}", "loc.browser.back": "Вяртаемся да папярэдняй старонкі", "loc.browser.forward": "Пераходзім да наступнай старонкі", "loc.browser.capabilities": "Атрымалі capabilities браўзэра з settings файла: {0}", diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json index 8e94c7cf..033a23bc 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json +++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json @@ -1,5 +1,6 @@ { "loc.browser.arguments": "Got browser start arguments from settings file: {0}", + "loc.browser.excludedArguments": "Exclude browser arguments from settings file: {0}", "loc.browser.back": "Return to previous page", "loc.browser.forward": "Proceed to the next page", "loc.browser.capabilities": "Got browser capabilities from settings file: {0}", diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json index 30d55e97..ae6d35a2 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json +++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json @@ -1,5 +1,6 @@ { "loc.browser.arguments": "Получили стартовые аргументы браузера из settings файла: {0}", + "loc.browser.excludedArguments": "Исключение аргументов браузера из settings файла: {0}", "loc.browser.back": "Возврат на предыдущую страницу", "loc.browser.forward": "Перейти на следующую страницу", "loc.browser.capabilities": "Получили capabilities браузера из settings файла: {0}", diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/settings.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/settings.json index 86f79ce8..91daf8c8 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Resources/settings.json +++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/settings.json @@ -19,6 +19,7 @@ "download.prompt_for_download": "false", "download.default_directory": "./downloads" }, + "excludedArguments": [ "enable-automation" ], "startArguments": [], "pageLoadStrategy": "Normal" }, @@ -69,6 +70,7 @@ "download.prompt_for_download": "false", "download.default_directory": "./downloads" }, + "excludedArguments": ["enable-automation"], "startArguments": [] }, "safari": { @@ -90,6 +92,7 @@ "disable-popup-blocking": "true", "download.prompt_for_download": "false" }, + "excludedArguments": ["enable-automation"], "startArguments": [] }, "yandex": { 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 e891a99f..9f2064b1 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs @@ -157,11 +157,11 @@ public void Should_BePossibleTo_ScrollToTheCenter() const int accuracy = 1; var welcomeForm = new WelcomeForm(); welcomeForm.Open(); - welcomeForm.GetExampleLink(AvailableExample.Dropdown).JsActions.ScrollToTheCenter(); + welcomeForm.GetExampleLink(AvailableExample.Hovers).JsActions.ScrollToTheCenter(); var windowSize = AqualityServices.Browser.ExecuteScriptFromFile("Resources.GetWindowSize.js").ToString(); var currentY = AqualityServices.Browser.ExecuteScriptFromFile("Resources.GetElementYCoordinate.js", - welcomeForm.GetExampleLink(AvailableExample.Dropdown).GetElement()).ToString(); + welcomeForm.GetExampleLink(AvailableExample.Hovers).GetElement()).ToString(); var coordinateRelatingWindowCenter = double.Parse(windowSize) / 2 - double.Parse(currentY); Assert.LessOrEqual(Math.Abs(coordinateRelatingWindowCenter), accuracy, "Upper bound of element should be in the center of the page"); } 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 7972685c..80109fe4 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.azure.json +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.azure.json @@ -19,7 +19,9 @@ "download.prompt_for_download": "false", "download.default_directory": "./downloads" }, - "startArguments": [] + "excludedArguments": [ "enable-automation" ], + "startArguments": [], + "pageLoadStrategy": "Normal" }, "firefox": { "webDriverVersion": "0.24.0", @@ -66,6 +68,7 @@ "download.prompt_for_download": "false", "download.default_directory": "./downloads" }, + "excludedArguments": [ "enable-automation" ], "startArguments": [] }, "safari": { diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.json b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.json index e4ba09e6..d06f9632 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.json +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.json @@ -19,6 +19,7 @@ "download.prompt_for_download": "false", "download.default_directory": "./downloads" }, + "excludedArguments": [ "enable-automation" ], "startArguments": [], "pageLoadStrategy": "Normal" }, @@ -70,6 +71,7 @@ "download.prompt_for_download": "false", "download.default_directory": "./downloads" }, + "excludedArguments": ["enable-automation"], "startArguments": [] }, "safari": { @@ -90,6 +92,7 @@ "disable-popup-blocking": "true", "download.prompt_for_download": "false" }, + "excludedArguments": ["enable-automation"], "startArguments": [] }, "yandex": { diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/AqualityServicesTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/AqualityServicesTests.cs index 3fd46b5c..6804865f 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/AqualityServicesTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/AqualityServicesTests.cs @@ -63,6 +63,16 @@ public void Should_BeAbleGetBrowser_WithStartArguments(string startArguments) Assert.DoesNotThrow(() => AqualityServices.Browser.WaitForPageToLoad()); } + [TestCase(null)] + [TestCase("enable-automation")] + [TestCase("a")] + public void Should_BeAbleGetBrowser_WithExcludedArguments(string excludedArguments) + { + var currentBrowser = AqualityServices.Get().BrowserName; + Environment.SetEnvironmentVariable($"driverSettings.{currentBrowser.ToString().ToLowerInvariant()}.excludedArguments", excludedArguments); + Assert.DoesNotThrow(() => AqualityServices.Browser.WaitForPageToLoad()); + } + [Ignore("Not all browsers are supported in Azure CICD pipeline")] [TestCase(BrowserName.IExplorer)] [TestCase(BrowserName.Firefox)]