When using Selenium automated testing, so ChromeDriver not display "is being test automation software control"

background:

In doing automated testing with Selenium, the default ChromeDriver will prompt "Chrom is being test automation software control". Below this. But we are under some scenarios, you do not want this prompt appears. This article explores several methods to remove this language tips article, we want to help small partners.

 

 1. Java

ChromeOptions options = new ChromeOptions(); 
options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"}); 
WebDriver driver = new ChromeDriver(options); 

2. C#

ChromeOptions options = new ChromeOptions();
options.AddExcludedArgument("enable-automation");
options.AddAdditionalCapability("useAutomationExtension", false);
IWebDriver driver = new ChromeDriver(options);
driver.Navigate().GoToUrl("http://www.baidu.com");

3. Python

chrome_options = webdriver.ChromeOptions(); 
chrome_options.add_experimental_option("excludeSwitches", ['enable-automation']);
driver = webdriver.Chrome(options=chrome_options);

4. JavaScript

var chromeCapabilities=webdriver.Capabilities.chrome()
var chromeOptions = {
        'excludeSwitches': ['enable-automation']
};
chromeCapabilities.set('chromeOptions', chromeOptions);
var driver = new webdriver.Builder()
    .withCapabilities(chromeCapabilities)
    .build();

 

  

Guess you like

Origin www.cnblogs.com/cc299/p/12032406.html