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

标签 selenium selenium-webdriver

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

enter image description here

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

最佳答案

由于不知道您正在使用哪种语言绑定(bind),因此为您提供消除这些消息的确切代码有点困难,但对于 IE 和 Chrome 的驱动程序,您希望获得 - -silent 开关在命令行上传递。对于 .NET 绑定(bind),这意味着在相应的服务类上设置属性并将这些属性传递到驱动程序构造函数中。对于 IE,该代码如下所示

InternetExplorerDriverService service = InternetExplorerDriverService.CreateDefaultService();
service.SuppressInitialDiagnosticInformation = true;
IWebDriver driver = new InternetExplorerDriver(service);

与 Chrome 类似,您需要类似的东西

ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.SuppressInitialDiagnosticInformation = true;
IWebDriver driver = new ChromeDriver(service);

关于selenium - 如何关闭 Selenium 中的日志记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34500192/

相关文章:

android - 如何使用appium在移动应用程序中查找xpath

python - clickAndHold 在 Selenium webdriver (python) 中不起作用

ajax - 如何通过selenium webdriver跟踪ajax请求和响应?

python - 属性错误 : 'module' object has no attribute 'webdriver'

vba - 刮刀点击下一页按钮,但什么也没得到

java - Selenium Webdriver 在打开的 Firefox 中失败

java - DOM 中两个不同元素的 Xpath OR 条件

python - 使用Python + Selenium进行基于 Electron 的应用测试

angularjs - 异步脚本超时

java - 如何使用java处理phantomjs selenium中的javascript错误?