42

I am running automated tests in Chrome with Serenity BDD (Selenium).

I had to download a new ChromeDriver, because my tests could not run -> The test would open ChromeDriver but could not "Browse as user". When I googled the issue, they said I had to update ChromeDriver.

So I updated ChromeDriver to version 2.28 and I also updated the Chrome version to Version 57.0.2987.98.

But now - EVERY TIME I run my tests this annoying text comes up:

Chrome is being controlled by automated test software

And it asks me if I want to save password. (I can't add pictures because I don't have enough "points")

In the previous version, I had managed to block these 2 things by:

public class CustomChromeDriver implements DriverSource {

    @Override
    public WebDriver newDriver() {
        try {
            DesiredCapabilities capabilities = DesiredCapabilities.chrome();
            Proxy proxy = new Proxy();
            String proxyServer = String.format("AProxyIDontWantToDisplay", System.getenv("proxy.username"), System.getenv("proxy.password"));
            proxy.setHttpProxy(proxyServer);
            capabilities.setCapability("proxy", proxy);
            ChromeOptions options = new ChromeOptions();
            options.addArguments(Arrays.asList("--no-sandbox","--ignore-certificate-errors","--homepage=about:blank","--no-first-run"));
            capabilities.setCapability(ChromeOptions.CAPABILITY, options);
            ChromeDriver driver = new ChromeDriver(capabilities);
            return driver;
        } catch (Exception e) {
            throw new Error(e);
        }
    }

    @Override
    public boolean takesScreenshots() {
        return true;
    }
}

I know there is this one (A link to same issue), but there are too many answers that don't work.

Anybody that knows how to remove that?

4
  • About the "controlled by automation" text pop up: is there an issue it's causing? I was messing with the chrome driver the other day and it didn't show up screenshots, etc, and wasn't causing any element interaction issues. Mar 31, 2017 at 14:30
  • No not really, i have some components under that pop up that wont be shown in screenshots when they are clicked. thats why :)
    – BobbyB
    Mar 31, 2017 at 15:12
  • Is this able to navigate URL and interact elements ?
    – NarendraR
    Mar 31, 2017 at 15:26
  • @BobbyB did you try taking the screenshot and seeing if they were covered? Like I stated, I didn't see the popup in the screenshots I took the other day. Mar 31, 2017 at 17:43

18 Answers 18

38

Add this to the options you pass to the driver:

options.addArguments("disable-infobars");
3
  • 10
    That answer was from over 3 years ago. Chrome might have changed the argument. This might help
    – jgode
    Dec 7, 2020 at 16:08
  • don't work for me in JavaScript Apr 3, 2022 at 20:22
  • 2024 - not working
    – Alex Sham
    Apr 13 at 13:45
32

Previously, passing the "disable-infobars” ChromeOption to the WebDriver prevented Chrome from displaying this notification. Recently, the "disable-infobars" option has been deprecated and no longer removes the notification. The current workaround for this is to pass in an option called "excludeSwitches" and then exclude the "enable_automation" switch.

ChromeOptions options = new ChromeOptions(); 
options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"}); 
WebDriver driver = new ChromeDriver(options); 
6
  • 2
    This solution does not stop the notification from being displayed when used in Java. Only options.addArguments("disable-infobars"); works fine Apr 5, 2017 at 15:12
  • 1
    To disable Notifications add this : options.addArguments("--disable-notifications"); Apr 5, 2017 at 15:21
  • 2
    While I agree that in nearly all cases it won't affect your testing, in my case it did, big time. The application I was trying to automate was not adjusting the screen drawing to the reduced real-estate when the info-bar was displayed and consequently critical elements that I needed to confirm as clickable were not because they were obscured by other elements. This is clearly a programming/design issue by the developers, but disabling the info-bars fixed my problem, the screen displayed correctly when they were gone. Apr 26, 2019 at 14:52
  • 5
    disable-infobars is not supported anymore for the latest drivers (76.0). Check @Rajeev 's answer for java and my answer for C#.
    – JM217
    Sep 4, 2019 at 5:32
  • 2
    @BillHileman I have modified the answer with the latest working code Dec 13, 2019 at 17:50
12

"disable-info" switch is not supported anymore for the latest chromedrivers. (at least 76.0).
@Rajeev's answer works and here I write the counterpart for C#.

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddAdditionalCapability("useAutomationExtension", false);
chromeOptions.AddExcludedArgument("enable-automation");
Driver = new ChromeDriver(chromeOptions);
5
  • This is woked for me
    – Wang Liang
    Nov 12, 2019 at 8:39
  • Hi @David Piao, I don't have any AddAdditionalOption method on ChromeOptions class, am I missing something?
    – XavierAM
    Jan 5, 2020 at 11:35
  • Are you sure you are using C#/Selenium?
    – JM217
    Jan 5, 2020 at 15:03
  • 2
    if you don't have AddAdditionalOption, check for AddAdditionalCapability
    – Fidan
    Feb 7, 2020 at 8:33
  • Thanks for the answer! It's very dissatisfying that there is no comprehensive resource for Chrome capabilities...
    – BVengerov
    May 7, 2020 at 13:33
8
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("useAutomationExtension", false);
options.setExperimentalOption("excludeSwitches",Collections.singletonList("enable-automation"));    
WebDriver driver = new ChromeDriver(options);

Use the above codes for latest Chrome drivers.

0
6

Works on 2022

remove Chrome is being controlled by automated test software in python

from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.chrome.options import Options

chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_experimental_option("excludeSwitches", ['enable-automation']);
URL = "https://google.com/"
driver.get(URL)
5

Tried many of these suggested solutions, but none of them worked. OK, my code is in C#, so there might be some differences in the WebDriver implementations for different platforms.

Anyway, the solution that I got working was using the following options for Chrome when running on .NET.

var options = new ChromeOptions();
options.AddExcludedArguments("enable-automation");

On .NET there doesn't seem to be any setExperimentalOption() method on the ChromeOptions class.

1
  • Jan 2023 - This solution works great on my part. Jan 31, 2023 at 6:19
4

While the disable-infobars route will work, it will likely suppress the infobar in all cases (as suggested here), not just the case that the OP is referring to. This is overkill at best, and could lead to unexpected and inexplicable behavior in the future if you are not getting some important message.

I think it's better to leverage the provided enable-automation switch by disabling it in the excludeSwitches area of your config/setup while doing nothing with regards to disable-inforbars. The enable-automation switch's description:

Inform users that their browser is being controlled by an automated test.

For nightwatch.conf.js it would look something like this (and worked for me):

desiredCapabilities: {
  ...
  chromeOptions: {
    excludeSwitches: ['enable-automation'],
    ...
  }
}

This should only do what we are after: getting rid of that specific pesky message!

Edit [2017-11-14]: This is now causing an even more annoying Disable Developer Mode Extensions alert/warning. I've tried every relevant-looking flag/switch I could find that might help, but to no avail. I've filed a bug with Chromium, so we'll see and I'll try to swing back through here if I get a resolution.

3

"disable-infobars" flag has been deprecated, but you can avoid this message by adding the following:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("useAutomationExtension", false);
chromeOptions.setExperimentalOption("excludeSwitches",Collections.singletonList("enable-automation"));    
WebDriver driver = new ChromeDriver(chromeOptions);
2

May someone needs this for Capybara, Watir should be like this:

Capybara.register_driver :chrome do |app|
  $driver = Capybara::Selenium::Driver.new(app, {:browser => :chrome, :args => [ "--disable-infobars" ]})
end
2

Protractor solution:

I arrived here searching for a Protractor solution, if useful for anyone I found, with help from the above answers; with Protractor you can add Chrome specific options to the chromeOptions object, within the capabilities object in the protractor.config file, for example to use the disable-infobars option discussed above use the following:

capabilities: {
  'browserName': 'chrome',
  'chromeOptions': {
    'args': ['disable-infobars']
  }
},

To use the enable-automation also discussed above:

capabilities: {
  'browserName': 'chrome',
  'chromeOptions': {
    'excludeSwitches': ['enable-automation']
  }
}

disable-infobars is preferred in my circumstances.

2

It works for me, with this code I am able to disable Chrome is being controlled by automated test software as well as the Save password popup`

    Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("credentials_enable_service", false);

ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("excludeSwitches",Collections.singletonList("enable-automation"));
options.setExperimentalOption("prefs", prefs);

WebDriver driver = new ChromeDriver(options)
0
Map<String, Object> prefs = new HashMap<String, Object>();
//To Turns off multiple download warning
prefs.put("profile.default_content_settings.popups", 0);

prefs.put( "profile.content_settings.pattern_pairs.*.multiple-automatic-downloads", 1 );

//Turns off download prompt
prefs.put("download.prompt_for_download", false);
                    prefs.put("credentials_enable_service", false);
//To Stop Save password propmts
prefs.put("password_manager_enabled", false);

ChromeOptions options = new ChromeOptions();
options.addArguments("chrome.switches","--disable-extensions");
//To Disable any browser notifications
options.addArguments("--disable-notifications");
//To disable yellow strip info bar which prompts info messages
options.addArguments("disable-infobars");

options.setExperimentalOption("prefs", prefs);
System.setProperty("webdriver.chrome.driver", "Chromedriver path");
options.addArguments("--test-type");
driver = new ChromeDriver(options);
Log.info("Chrome browser started");
0

It works for me by using addArguments(array("disable-infobars"))

This is for facebook/php-webdriver

$options = new ChromeOptions();
$options->addArguments(array("disable-infobars"));
$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
$this->driver = RemoteWebDriver::create('http://localhost:4444/wd/hub', $capabilities);
0

You may use this

options1.add_argument("--app=https://www.google.com.ph")
0

I tried almost every option from GitHub currently with those options I don't get additional browser page.

chrome_options = Options()
chrome_options.add_argument("--remote-debugging-port=9222")
chrome_options.add_argument("--headless") # this changes the behavior 
driver = webdriver.Chrome(options=chrome_options)

Version info

2023-12-28 Thu 17:55  
google-chrome --version
Google Chrome 120.0.6099.129
pip list | grep selenium
selenium               4.16.0
-1

If anyone is using Rails 5.1+, which changed the testing structure a bit and Capybara is configured in this file now for system tests:

application_system_test_case.rb

You can add "args" in the options for driven_by like this:

driven_by :selenium, using: :chrome, screen_size: [1400, 1400], options: { args: ["--disable-infobars"] }
-1
public WebDriver SetupChromeDriver(){
        //Initialize Chrome Driver
        ChromeOptions options = new ChromeOptions();
        Map<String, Object> prefs = new HashMap<String, Object>();
        prefs.put("safebrowsing.enabled", "true"); 
        options.setExperimentalOption("prefs", prefs); 
        options.addArguments("--disable-notifications");
        options.addArguments("--start-maximized");
        options.addArguments("disable-infobars");
        System.setProperty("webdriver.chrome.driver", "E:/Importent Softwares/Chrome Driver/chromedriver_2.37.exe");
        driver = new ChromeDriver(options);
        return driver;
}
-1

It took a lot of fiddling but eventually I found a combination of flags that works in 2021!

This tells Chrome to ignore all SSL errors, disables the "Chrome is being controlled by automated test software" message and starts in full screen. Add it to the Target field of your shortcut:

"C:\Program Files\Google\Chrome\Application\chrome.exe" --ignore-certificate-errors --test-type=webdriver --start-fullscreen

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.