Home > front end >  Selenium Java Chrome remove flag
Selenium Java Chrome remove flag

Time:12-14

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

CodePudding user response:

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);

  • Related