Reputation: 206
I am using selenium 4 with webdriver manager, running tests headless on chrome. I want to silence logs. I looked through similiar questions and I managed to silence few logs by adding code below, but I still receive a few, which is annoying when running tests in parallel.
I put Logger.getLogger("org.openqa.selenium").setLevel(Level.SEVERE)
in before method and this is my method to create driver:
@Override
public WebDriver createDriverHeadless() {
WebDriverManager.chromedriver().cachePath("drivers").setup();
ChromeOptions options = new ChromeOptions();
System.setProperty("webdriver.chrome.silentLogging", "true");
System.setProperty("webdriver.chrome.silentOutput", "true");
options.setHeadless(true);
options.addArguments(
"--disable-gpu",
"--window-size=1920,1080",
"--ignore-certificate-errors",
"--disable-extensions",
"--no-sandbox",
"--disable-dev-shm-usage",
"--log-level=3"
);
return new ChromeDriver(options);
}
yet, I cant get rid of these logs:
How can I silence these?
Upvotes: 1
Views: 1011
Reputation: 193108
You get rid of these logs by adding the following experimental_option:
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-logging"));
Upvotes: 1