After updating Chrome to version 76, I cannot figure out how to hide the \"Chrome is being controlled by automated software...\" notification overriding some controls on the
As of 1 Aug 2019 - You can send the excludeswitch - enable-automation to hide the message. and to disable pop up 'Disable developer mode extensions' set useAutomationExtension=false . Refer for useAutomationExtension
Tested on : Windows 10 Version 76.0.3809.87 (Official Build) (64-bit) ChromeDriver 76.0.3809.68
--enable-automation : Inform users that their browser is being controlled by an automated test Reference
"goog:chromeOptions": {
"excludeSwitches": [ "enable-automation" ],
"useAutomationExtension": false
}
In C# :
To disable pop up "Disable developer mode extensions" and automation info-bar message .
options.AddExcludedArgument("enable-automation");
options.AddAdditionalCapability("useAutomationExtension", false);
In JAVA :
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);
In Python :
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
In Protractor :
Add below capabilities in conf.js/conf.ts
capabilities: {
'browserName': 'chrome',
"goog:chromeOptions": {
"excludeSwitches": [ "enable-automation" ],
"useAutomationExtension": false
}
},
Apparently you can use the CommandLineFlagSecurityWarningsEnabled chrome policy - https://www.chromium.org/administrators/policy-list-3#CommandLineFlagSecurityWarningsEnabled
On Linux I was able to create a file at /etc/opt/chrome/policies/managed/managed_policies.json with the contents: {"CommandLineFlagSecurityWarningsEnabled": false}
and this disabled the warning.
On Windows 10 Pro when I set the Chrome group policy "Enable security warnings for command-line flags" to disabled (see https://support.google.com/chrome/a/answer/187202) and check the registry at Software\Policies\Google\Chrome\CommandLineFlagSecurityWarningsEnabled for a value of 0x00000000 it doesn't work for me to disable this warning. Maybe it will for you? Wondering if someone else can help shed light on why it won't work on Windows
To hide "Chrome is being controlled by automated test software" infobar in C# for Chrome v76:
var chromeOptions = new ChromeOptions();
...
chromeOptions.AddAdditionalCapability("useAutomationExtension", false);
chromeOptions.AddExcludedArgument("enable-automation");
...
var driver = new ChromeDriver(ChromeDriverService.CreateDefaultService(), chromeOptions, commandTimeout);
Chromium team earlier introduced the infobar Chrome is being controlled by automated test software
to disable Developer mode extension
popup within Chrome Browser through this commit.
As per the discussion Flakiness due to Chrome automation infobar (Chrome 57+) with the addition of the infobar to display if a session is being controlled by an automated test within Chrome it was observed that the presence of Chrome automation infobar Chrome is being controlled by automated test software
intermitently caused the click()
function to fail. During the tests, when the the infobar was removed by passing disable-infobars
within chrome_launcher.cc
then the above tests runs as expected without any issues. gmanikpure@chromium.org confirmed that the culprit was the changelog:
Add an infobar if a session is being controlled by an automated test.
This infobar is only displayed if the browser is launched with the --enable-automation switch. It also disables the developer mode extensions warning bubble.
TEST=launch with and without --enable-automation, and check for presence of automation infobar
It was observed that, during a click the infobar animation occurs and we got flaky results. So Chromium team needed to detect this change somehow and recompute the position. The actual problem was, if a Page.frameResized occured we can invalidate the results of some operations and retry (e.g. get element position) but there were other operations that can modify the page, such as mouse clicks. It's possible that a mouse click (which involves a mousemove, mousedown and a mouseup event) can have a resize event in the middle.
Accordingly, Chromium team released a revision through this commit:
Disable info bar animations during automated testing.
Since then Chrome user, to disable the infobar started using:
Java:
options.addArguments("disable-infobars");
Python:
options.add_argument("disable-infobars")
C#:
option.AddArguments("disable-infobars");
Now in the discussion Chrome is being controlled by automated test software infobar doesn't gets suppressed despite using disable-infobars argument Chromium team member triciac@chromium.org clearly mentioned:
As of v 76, the ability to suppress the infobar was moved from command line options to Enterprise Policy settings for Chrome.
The change was already mentioned in the Release Notes and Chrome Enterprise release notes as follows
--disable-infobars is no longer supported
Chrome will no longer support the --disable-infobars flag, which was used to hide pop-up warnings
from Chrome Browser. To support automated testing, kiosks, and automation, the
CommandLineFlagSecurityWarningsEnabled policy was added to allow you to disable some security
warnings.
So, from Chrome v76.x onwards --disable-infobars
flag is officially deprecated.
The policy is not an option or a capability that is set when ChromeDriver or Chrome is launched as security policies are typically managed by your corporate IT department. Hence usage of disable-infobars
have been deprecated.
The --disable-infobars
flag can still removed from Chrome v76.x using these 2(two) ExperimentalOption:
Excluding
the switches for enable-automation
useAutomationExtension
to False
Here are the implementations:
Java:
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);
WebDriver driver = new ChromeDriver(options);
driver.get("https://google.com");
Python:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
driver.get('https://www.google.co.in')
As per the article CommandLineFlagSecurityWarningsEnabled:
Enable security warnings for command-line flags
Supported on: Google Chrome (Linux, Mac, Windows) since version 76
Description: If disabled, prevents security warnings from appearing when Chrome is launched with some potentially dangerous command-line flags.
If enabled or unset, security warnings are displayed when some command-line flags are used to launch Chrome.
On Windows, this policy is only available on instances that are joined to a Microsoft Active Directory domain or Windows 10 Pro or Enterprise instances that are enrolled for device management.
This will work in C#:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--incognito");
chromeOptions.AddExcludedArgument("enable-automation");
chromeOptions.AddAdditionalCapability("useAutomationExtension", false);
You can use --app=desired_address_without_brackets
flag, e.g. --app=https://google.com
. Works in Chrome 80.
Of course it works only if it's acceptable for your project to be launched in App mode and you have a page link you can insert there. See this answer of mine for a little more info.
You can also use --test-type
command line flag, which removes such infobars too.
Attention! In very rare cases it causes strange things like muting page sound! So I'm not sure I should recommend it in the first place.