Resolved "chrome is being controlled by automated testing software" information bar display issue

When using Selenium WebDriver to start Google Chrome, a line of prompt information is often displayed below the address bar of the newly launched browser: "chrome is being controlled by automated testing software", the English is "'Chrome is being controlled by automated test. software'.

We can solve this problem by introducing the ChromeOptions class. Some methods defined in the ChromeOptions class can specify the Chrome browser to start in a specific way. By passing the parameter "disable-infobars", you can make the Chrome browser not display at startup. Information Bar.

The following is an example of a solution based on the Java language:

1  package learnwebdriver;  
 2    
3  import org.openqa.selenium.WebDriver;  
 4  import org.openqa.selenium.chrome.ChromeDriver;  
 5  import org.openqa.selenium.chrome.ChromeOptions;  
 6    
7  public  class UseBrowserChrome {  
 8    
9      public  static  void main(String[] args) {  
 10            
11          System.setProperty("webdriver.chrome.driver", "D:\\BrowserDriver\\chromedriver.exe" );  
 12            
13          // Cancel chrome being controlled by automatic test software Information field   
14         ChromeOptions options = new ChromeOptions();  
15         options.addArguments("disable-infobars");  
16           
17         //带参数启动Chrome浏览器  
18         WebDriver driver = new ChromeDriver(options);         
19           
20         driver.manage().window().maximize();          
21           
22         driver.get("http://www.baidu.com/");  
23           
24           
25         //driver.quit();  
26           
27   
28     }  
29   
30 }  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324970969&siteId=291194637