我正在尝试使用Selenium WebDriver获取性能日志,代码如下:
DesiredCapabilities cap = DesiredCapabilities.firefox();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
cap.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
WebDriver driver = new FirefoxDriver(cap);
driver.get("http://www.google.com");
System.out.println("Performance: " + driver.manage().logs().get(LogType.PERFORMANCE).getAll());
for (LogEntry entry : driver.manage().logs().get(LogType.PERFORMANCE)) {
System.out.println("Entry: " + entry.toString());
}
driver.quit();
运行上面的代码后,我没有得到任何回报作为日志。如果你看到行的输出:
System.out.println("Performance: " + driver.manage().logs().get(LogType.PERFORMANCE).getAll());
它返回空数组。你能告诉我这里做错了什么吗?