如何关闭 Selenium 中的日志记录?

3 selenium selenium-webdriver

我的控制台被来自 ChromeDriver 和 IEDriver 的不需要的日志消息填满了。

在此处输入图片说明

我试过:Console.SetOut(TextWriter.NULL);但这不起作用。我尝试了各种实现,driver.setCapabilities(LOGGING, NOOOOO)但没有任何效果。

Jim*_*ans 5

Not knowing exactly which language bindings you're using, it's a little challenging to give you the exact code to eliminate those messages, but in the case of the drivers for IE and Chrome, you want to get the --silent switch passed on the command line. For the .NET bindings, that means setting properties on the respective service classes and passing those into the driver constructor. For IE, that code would look like

InternetExplorerDriverService service = InternetExplorerDriverService.CreateDefaultService();
service.SuppressInitialDiagnosticInformation = true;
IWebDriver driver = new InternetExplorerDriver(service);
Run Code Online (Sandbox Code Playgroud)

Similarly for Chrome, you'd want something like

ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.SuppressInitialDiagnosticInformation = true;
IWebDriver driver = new ChromeDriver(service);
Run Code Online (Sandbox Code Playgroud)