当我运行Java Selenium测试时,Eclipse控制台会显示很多消息,例如:

1484171436147   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"]
1484171436149   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"]
1484171436152   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/GMPProvider.jsm
1484171436154   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/PluginProvider.jsm
1484171436154   addons.manager  DEBUG   Starting provider: XPIProvider
1484171436155   addons.xpi  DEBUG   startup
1484171436155   addons.xpi  INFO    SystemAddonInstallLocation directory is missing
1484171436156   addons.xpi  INFO    Mapping [email protected] to C:\Program Files (x86)\Firefox Developer Edition\browser\features\[email protected]
1484171436156   addons.xpi  INFO    Mapping [email protected] to C:\Program Files (x86)\Firefox Developer Edition\browser\features\[email protected]
1484171436157   addons.xpi  INFO    Mapping [email protected] to C:\Program Files (x86)\Firefox Developer Edition\browser\features\[email protected]


我想要一个更干净的日志。我从其他问题中尝试了很多方法,但是没有任何效果。垃圾还在那里。

这是我现在在测试服中@BeforeClass方法中拥有的内容:

LoggingPreferences loggingPrefs = new LoggingPreferences();
loggingPrefs.enable(LogType.BROWSER, Level.WARNING);
loggingPrefs.enable(LogType.CLIENT, Level.WARNING);
loggingPrefs.enable(LogType.DRIVER, Level.WARNING);
loggingPrefs.enable(LogType.PERFORMANCE, Level.WARNING);
loggingPrefs.enable(LogType.PROFILER, Level.WARNING);
loggingPrefs.enable(LogType.SERVER, Level.WARNING);
desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPrefs);

driver = new FirefoxDriver(desiredCapabilities);


如何清理我的日志?

最佳答案

我在Selenium用户论坛上找到了an answer

    if (driver instanceof RemoteWebDriver) {
          ((RemoteWebDriver) driver).setLogLevel(Level.WARNING);
    }


创建驱动程序对象后立即使用此命令解决了我的问题。

09-05 20:28