This tutorial explains the steps to disable infobar warning generated by Selenium for running tests in Chrome. Selenium tests run on Chrome shows a warning message – “Chrome is being controlled by automated test software as shown in the below image.“

We want to run the Selenium tests on Chrome, but without the above-shown warning message. This can be achieved by using excludeSwitches.
chromeOptions.setExperimentalOption("excludeSwitches", Arrays.asList("enable-automation"));
The complete program is shown below:
import java.util.Arrays;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import io.github.bonigarcia.wdm.WebDriverManager;
public class ChromeDisableInfobars {
public static void main(String[] args) {
WebDriverManager.chromedriver().setup();
// Create an object of Chrome Options class
ChromeOptions chromeOptions = new ChromeOptions();
// prevents Chrome from displaying the notification 'Chrome is being controlled
// by automated software'
chromeOptions.setExperimentalOption("excludeSwitches", Arrays.asList("enable-automation"));
// Create an object of WebDriver class and pass the Chrome Options object as an
// argument
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://duckduckgo.com/");
System.out.println("Title of Page :" + driver.getTitle());
// close the browser
driver.quit();
}
}
The output of the above program is


We are done. Congratulations!! Happy Learning.