【问题标题】:How to decrease verbosity of Gecko Driver's logs?如何减少 Gecko Driver 日志的详细程度?
【发布时间】:2019-05-27 20:49:02
【问题描述】:

当我开始最小的 Selenium 测试时,我得到了奇怪的日志(不确定它是否是 Gecko 驱动程序的)。如何禁用这些注销如何解决这些问题?

import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxDriverLogLevel;
import org.openqa.selenium.firefox.FirefoxOptions;

public class ffruntest {

    public static void main(String[] args) {
        FirefoxOptions options = new FirefoxOptions();
        options.setLogLevel(FirefoxDriverLogLevel.FATAL);

        FirefoxDriver driver = new FirefoxDriver(options);
        driver.quit();
    }
}

日志:

1546245354514   addons.webextension.screenshots@mozilla.org WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid host permission: resource://pdf.js/
1546245354514   addons.webextension.screenshots@mozilla.org WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid host permission: about:reader*
dec 31, 2018 11:35:57 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[Child 13180, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 13180, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Parent 8104, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 21768, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 21768, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[RDD 28500, Chrome_ChildThrJavaScript error: resource://gre/modules/osfile/osfile_async_front.jsm, line 409: Error: OS.File has been shut down. Rejecting post to remove
JavaScript error: resource://gre/modules/osfile/osfile_async_front.jsm, line 409: Error: OS.File has been shut down. Rejecting post to remove
JavaScript error: resource://gre/modules/Sqlite.jsm, line 841: Error: Connection is not open.
JavaScript error: resource://gre/modules/IndexedDB.jsm, line 349: UnknownError: The operation failed for reasons unrelated to the database itself and not covered by any other error code.

Process finished with exit code 0

如您所见,我已经使用了this post 中描述的 FF 选项,它有助于删除一些东西,但不是全部。

  • FireFox 65.0b7(64 位),无活动插件,无插件
  • geckodriver 0.23.0 (2018-10-04)
  • 硒 3.14.0

【问题讨论】:

    标签: java selenium selenium-webdriver geckodriver gecko


    【解决方案1】:

    您可以将它们设置为 false。

    System.setProperty("webdriver.chrome.verboseLogging", "false");
    

    或者你可以重定向日志

    System.setProperty("webdriver.chrome.logfile", logsPath());
    

    谢谢

    【讨论】:

    • 不幸的是,它没有多大帮助。日志仍然存在。
    【解决方案2】:

    对于 Firefox(和 geckodriver),您可以尝试以下任一方法:

    System.setProperty("webdriver.firefox.logfile", "/dev/null");

    或者使用命令行参数-Dwebdriver.firefox.logfile=/dev/null运行测试

    如果您在 Windows 上运行此程序,请选择合适的文件位置来代替 /dev/null

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多