Skip to content

Commit a1a255c

Browse files
MikhailKalynMikhail Kalyn
andauthored
Add possibility to hide "<BrowserName> is being controlled by automated software" infobar (#212)
* Add possibility to hide "Chrome is being controlled by automated software" infobar within Chrome * Update settings * Add ExcludedArguments into EdgeOptions and OperaOptions * Add test with different excludedArguments * Add logger localization messages * Fix autotest Co-authored-by: Mikhail Kalyn <[email protected]>
1 parent 3157da0 commit a1a255c

File tree

12 files changed

+62
-4
lines changed

12 files changed

+62
-4
lines changed

Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/ChromeSettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ public override DriverOptions DriverOptions
3030
SetChromePrefs(options);
3131
SetCapabilities(options, (name, value) => options.AddAdditionalOption(name, value));
3232
SetChromeArguments(options);
33+
SetChromeExcludedArguments(options);
3334
SetPageLoadStrategy(options);
3435
return options;
3536
}
3637
}
3738

39+
private void SetChromeExcludedArguments(ChromeOptions options)
40+
{
41+
options.AddExcludedArguments(BrowserExcludedArguments);
42+
}
43+
3844
private void SetChromePrefs(ChromeOptions options)
3945
{
4046
foreach (var option in BrowserOptions)

Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public abstract class DriverSettings : IDriverSettings
1818
private IReadOnlyDictionary<string, object> options;
1919
private IReadOnlyDictionary<string, object> capabilities;
2020
private IReadOnlyList<string> startArguments;
21+
private IReadOnlyList<string> excludedArguments;
2122

2223
/// <summary>
2324
/// Instantiates class using JSON file with general settings.
@@ -90,19 +91,36 @@ protected IReadOnlyDictionary<string, object> BrowserOptions
9091
}
9192
}
9293

94+
protected IReadOnlyList<string> BrowserExcludedArguments
95+
{
96+
get
97+
{
98+
if (excludedArguments == null)
99+
{
100+
excludedArguments = SettingsFile.GetValueListOrEmpty<string>($"{DriverSettingsPath}.{nameof(excludedArguments)}");
101+
if (excludedArguments.Any())
102+
{
103+
AqualityServices.LocalizedLogger.Debug("loc.browser.excludedArguments", args: string.Join(" ", excludedArguments));
104+
}
105+
}
106+
107+
return excludedArguments;
108+
}
109+
}
110+
93111
protected IReadOnlyList<string> BrowserStartArguments
94112
{
95113
get
96114
{
97115
if (startArguments == null)
98116
{
99117
startArguments = SettingsFile.GetValueListOrEmpty<string>($"{DriverSettingsPath}.{nameof(startArguments)}");
100-
101118
if (startArguments.Any())
102119
{
103120
AqualityServices.LocalizedLogger.Debug("loc.browser.arguments", args: string.Join(" ", startArguments));
104121
}
105122
}
123+
106124
return startArguments;
107125
}
108126
}

Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/EdgeSettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ public override DriverOptions DriverOptions
3030
SetEdgePrefs(options);
3131
SetCapabilities(options, (name, value) => options.AddAdditionalOption(name, value));
3232
SetEdgeArguments(options);
33+
SetEdgeExcludedArguments(options);
3334
SetPageLoadStrategy(options);
3435
return options;
3536
}
3637
}
3738

39+
private void SetEdgeExcludedArguments(EdgeOptions options)
40+
{
41+
options.AddExcludedArguments(BrowserExcludedArguments);
42+
}
43+
3844
private void SetEdgePrefs(EdgeOptions options)
3945
{
4046
foreach (var option in BrowserOptions)

Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/OperaSettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@ public override DriverOptions DriverOptions
3131
SetOperaPrefs(options);
3232
SetCapabilities(options, (name, value) => options.AddAdditionalOption(name, value));
3333
SetOperaArguments(options);
34+
SetOperaExcludedArguments(options);
3435
SetPageLoadStrategy(options);
3536
return options;
3637
}
3738
}
3839

40+
private void SetOperaExcludedArguments(OperaOptions options)
41+
{
42+
options.AddExcludedArguments(BrowserExcludedArguments);
43+
}
44+
3945
private void SetOperaPrefs(OperaOptions options)
4046
{
4147
foreach (var option in BrowserOptions)

Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"loc.browser.arguments": "Атрымалі стартавыя аргументы браўзэра з settings файла: {0}",
3+
"loc.browser.excludedArguments": "Выключэнне аргументаў браўзэра з settings файла: {0}",
34
"loc.browser.back": "Вяртаемся да папярэдняй старонкі",
45
"loc.browser.forward": "Пераходзім да наступнай старонкі",
56
"loc.browser.capabilities": "Атрымалі capabilities браўзэра з settings файла: {0}",

Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"loc.browser.arguments": "Got browser start arguments from settings file: {0}",
3+
"loc.browser.excludedArguments": "Exclude browser arguments from settings file: {0}",
34
"loc.browser.back": "Return to previous page",
45
"loc.browser.forward": "Proceed to the next page",
56
"loc.browser.capabilities": "Got browser capabilities from settings file: {0}",

Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"loc.browser.arguments": "Получили стартовые аргументы браузера из settings файла: {0}",
3+
"loc.browser.excludedArguments": "Исключение аргументов браузера из settings файла: {0}",
34
"loc.browser.back": "Возврат на предыдущую страницу",
45
"loc.browser.forward": "Перейти на следующую страницу",
56
"loc.browser.capabilities": "Получили capabilities браузера из settings файла: {0}",

Aquality.Selenium/src/Aquality.Selenium/Resources/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"download.prompt_for_download": "false",
2020
"download.default_directory": "./downloads"
2121
},
22+
"excludedArguments": [ "enable-automation" ],
2223
"startArguments": [],
2324
"pageLoadStrategy": "Normal"
2425
},
@@ -69,6 +70,7 @@
6970
"download.prompt_for_download": "false",
7071
"download.default_directory": "./downloads"
7172
},
73+
"excludedArguments": ["enable-automation"],
7274
"startArguments": []
7375
},
7476
"safari": {
@@ -90,6 +92,7 @@
9092
"disable-popup-blocking": "true",
9193
"download.prompt_for_download": "false"
9294
},
95+
"excludedArguments": ["enable-automation"],
9396
"startArguments": []
9497
},
9598
"yandex": {

Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ public void Should_BePossibleTo_ScrollToTheCenter()
157157
const int accuracy = 1;
158158
var welcomeForm = new WelcomeForm();
159159
welcomeForm.Open();
160-
welcomeForm.GetExampleLink(AvailableExample.Dropdown).JsActions.ScrollToTheCenter();
160+
welcomeForm.GetExampleLink(AvailableExample.Hovers).JsActions.ScrollToTheCenter();
161161

162162
var windowSize = AqualityServices.Browser.ExecuteScriptFromFile<object>("Resources.GetWindowSize.js").ToString();
163163
var currentY = AqualityServices.Browser.ExecuteScriptFromFile<object>("Resources.GetElementYCoordinate.js",
164-
welcomeForm.GetExampleLink(AvailableExample.Dropdown).GetElement()).ToString();
164+
welcomeForm.GetExampleLink(AvailableExample.Hovers).GetElement()).ToString();
165165
var coordinateRelatingWindowCenter = double.Parse(windowSize) / 2 - double.Parse(currentY);
166166
Assert.LessOrEqual(Math.Abs(coordinateRelatingWindowCenter), accuracy, "Upper bound of element should be in the center of the page");
167167
}

Aquality.Selenium/tests/Aquality.Selenium.Tests/Resources/settings.azure.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"download.prompt_for_download": "false",
2020
"download.default_directory": "./downloads"
2121
},
22-
"startArguments": []
22+
"excludedArguments": [ "enable-automation" ],
23+
"startArguments": [],
24+
"pageLoadStrategy": "Normal"
2325
},
2426
"firefox": {
2527
"webDriverVersion": "0.24.0",
@@ -66,6 +68,7 @@
6668
"download.prompt_for_download": "false",
6769
"download.default_directory": "./downloads"
6870
},
71+
"excludedArguments": [ "enable-automation" ],
6972
"startArguments": []
7073
},
7174
"safari": {

0 commit comments

Comments
 (0)