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 page.
The latest stable release of ChromeDriver is indeed 76.0.3809.68. The following code worked with Chrome 75 and ChromeDriver 74.
var options = new ChromeOptions();
options.AddArgument("--test-type");
options.AddArgument("--disable-extensions");
options.AddArguments("disable-infobars");
options.AddArguments("--disable-notifications");
options.AddArguments("enable-automation");
options.AddArguments("--disable-popup-blocking");
options.AddArguments("start-maximized");
var driver = new ChromeDriver(driverLocation, options, ScriptTimeout);
An infobar is a graphical control element used by browsers including Firefox and Google Chrome and other software programs to display non-critical information to a user.
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
}
},
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. [email protected] 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 [email protected] 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);
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);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With