如何减少Gecko Driver日志的详细程度?

时间:2018-12-31 08:55:59

标签: java selenium selenium-webdriver geckodriver gecko

当我开始最小的硒测试时,我有奇怪的日志(不确定是否是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

2 个答案:

答案 0 :(得分:0)

您可以将它们设置为false。

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

或者您可以重定向日志

{{1}}

谢谢

答案 1 :(得分:0)

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

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

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

运行测试

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