Skip to content
Advertisement

Selenium Java Chrome remove flag

I want to hide that I use a Webdriver. I know the needed Code for Python:

option.add_experimental_option("excludeSwitches", ["enable-automation"])
option.add_experimental_option('useAutomationExtension', False)

but I want it for Java. I tried this but I get errors:

System.setProperty("webdriver.chrome.driver", path);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption('excludeSwitches', ['enable-automation']);
options.setExperimentalOption('useAutomationExtension', False);

WebDriver driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.get("");

I hope you can help me out.

Best Regards

Christian

Advertisement

Answer

In Java it will be

ChromeOptions options = new ChromeOptions();

options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);

WebDriver driver = new ChromeDriver(options);

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement