Chrome is being controlled by automated test software

后端 未结 13 1022
天涯浪人
天涯浪人 2020-12-01 10:49

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 Chro

相关标签:
13条回答
  • 2020-12-01 11:27

    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
    
    0 讨论(0)
  • 2020-12-01 11:31

    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); 
    
    0 讨论(0)
  • 2020-12-01 11:32

    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.

    0 讨论(0)
  • 2020-12-01 11:33

    "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);
    
    0 讨论(0)
  • 2020-12-01 11:34

    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.

    0 讨论(0)
  • 2020-12-01 11:37
    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 讨论(0)
提交回复
热议问题