35

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);
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
G. Victor
  • 545
  • 1
  • 6
  • 17

9 Answers9

70

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
   }
  },
Rahul L
  • 4,249
  • 15
  • 18
  • @g-victor Make sure to remove options.AddArguments("enable-automation"); this line from your code as well – Rahul L Aug 01 '19 at 08:43
  • infobar is hided. But issue cannot hide "Disable developer mode extensions pop up in Chrome" pop. I used next option: var options = new ChromeOptions(); options.AddArgument("--test-type"); options.AddArgument("--disable-extensions"); options.AddExcludedArgument("enable-automation"); options.AddArguments("start-maximized"); – G. Victor Aug 02 '19 at 07:53
  • As workaround add options.AddAdditionalOption("useAutomationExtension",false) – Rahul L Aug 02 '19 at 08:50
  • useAutomationExtension = false do not work @RahulL . "Developer mode extension..." still exit, though I need to use my extension for automate process. I used these option: chromeOptions.AddArguments("disable-infobars"); chromeOptions.AddArgument("--disable-blink-features=BlockCredentialedSubresources"); chromeOptions.AddArgument("--disable-notifications"); chromeOptions.AddUserProfilePreference("enable_do_not_track", true); chromeOptions.AddAdditionalCapability("useAutomationExtension", false); chromeOptions.AddExcludedArgument("enable-automation"); – duong khang Aug 15 '19 at 18:06
  • @duong-khang chromeOptions.useAutomationExtension. is only for clients to enable or disable the 'ChromeDriver automation extension' If you are loading some other extension i think you will get the ""Developer mode extension.." message – Rahul L Aug 16 '19 at 04:13
  • so is there any way to get rid of this pop up? it user do not click outside the pop up then the automation process will be stuck there – duong khang Aug 16 '19 at 08:40
  • As of now not aware of any other way. If you are ok with " "Chrome is being controlled by automated software..." message then remove chromeOptions.AddExcludedArgument("enable-automation"); . You will not get ""Developer mode extension.." message – Rahul L Aug 16 '19 at 08:47
16

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.


Conclusion

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.


A small Hack

The --disable-infobars flag can still removed from Chrome v76.x using these 2(two) ExperimentalOption:

  • Excluding the switches for enable-automation
  • Setting useAutomationExtension to False

Implementations

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')
    

Outro

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.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Since Chrome version 79 it is no longer supported – Elias Vargas Feb 24 '20 at 23:00
  • Why would someone want to disable chrome infobar ? – MasterJoe Mar 23 '20 at 19:05
  • 1
    @MasterJoe2 in some cases (mine included) the infobar causes the click() function to fail. Some tests can if fail the element is in the DOM but not visible in the viewport. The infobar seems to push the website's viewport down a little bit, hence making otherwise elements unclickable – Michael Dally Jun 11 '20 at 08:19
3

This will work in C#:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--incognito");
chromeOptions.AddExcludedArgument("enable-automation");
chromeOptions.AddAdditionalCapability("useAutomationExtension", false);
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
2

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);
Dima Dubyk
  • 152
  • 1
  • 7
2
  1. 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.

  2. 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.

RollingHog
  • 121
  • 7
1

In Ruby, for the selenium-webdriver gem, which is often used with Capybara, use ::Selenium::WebDriver::Chrome::Options#add_option('excludeSwitches', ['enable-automation']).

For example:

Capybara.register_driver :selenium_chrome do |app|
  browser_options = ::Selenium::WebDriver::Chrome::Options.new
  browser_options.add_option 'excludeSwitches', ['enable-automation']
  Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end
Eliot Sykes
  • 9,616
  • 6
  • 50
  • 64
1

Another option in Ruby for me was:

Capybara.register_driver :selenium_chrome do |app|
  Capybara::Selenium::Driver.new(app, browser: :chrome, options: chrome_options)
end

def chrome_options
  options = Selenium::WebDriver::Chrome::Options.new
  options.add_option 'excludeSwitches', ['enable-automation']
  options.add_argument('incognito')
  options.add_argument('disable-geolocation')
  options.add_argument('ignore-certificate-errors')
  options.add_argument('disable-popup-blocking')
  options.add_argument('disable-web-security')
  options.add_argument('--disable-infobars')
  options.add_argument('disable-translate')
  options
end
CarolCiola
  • 111
  • 10
0

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

JJJ
  • 490
  • 4
  • 9
0

As was mentioned above, in Java just use:

chromeOptions.setExperimentalOption("excludeSwitches",Collections.singletonList("enable-automation"));

since:

chromeOptions.setExperimentalOption("useAutomationExtension", false);

is deprecated, and works same way.