gpt4 book ai didi

Java/ Selenium : Still getting "ChromeDriver was started successfully" message after disabling logging

转载 作者:行者123 更新时间:2023-12-03 20:51:14 24 4
gpt4 key购买 nike

我正在使用带有 Java 的 Selenium Chromedriver。我不希望它在控制台中输出任何日志/消息。因此我使用了以下代码:

    System.setProperty("webdriver.chrome.silentOutput", "true");
System.setProperty(ChromeDriverService.CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true");
Logger.getLogger("org.openqa.selenium").setLevel(Level.OFF);
但是,我仍然收到一条消息:“ChromeDriver 已成功启动”。如何阻止此消息?

最佳答案

您可以将输出重定向到文件或丢弃它:

            // redirect console output from chromedriver to the file chromedriver_log.txt in the target folder
DriverService.Builder<ChromeDriverService, ChromeDriverService.Builder> serviceBuilder = new ChromeDriverService.Builder();
ChromeDriverService chromeDriverService = serviceBuilder.build();
chromeDriverService.sendOutputTo(new FileOutputStream("target/chromedriver_log.txt", true));

webDriver = new ChromeDriver(chromeDriverService, options);
如果您只想丢弃输出,请使用 NullOutputStream.NULL_OUTPUT_STREAM插入 new FileOutputStream("target/chromedriver_log.txt", true)

关于Java/ Selenium : Still getting "ChromeDriver was started successfully" message after disabling logging,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62661007/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com