Selenium Web驱动程序:提取的Chrome浏览器日志不完整 [英] Selenium Web Driver: Extracted Chrome Browser logs are incomplete

查看:459
本文介绍了Selenium Web驱动程序:提取的Chrome浏览器日志不完整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Selenium的帮助下为Vaadin应用程序编写浏览器测试.开发实用程序中的Chrome浏览器日志控制台显示了不同日志级别(TRACE,SEVERE,WARNING)的日志.以下代码设置了我的测试驱动程序:

I'm writing browser tests for a Vaadin application with help of Selenium. The Chrome browser log console in development utilities shows logs of different log levels (TRACE, SEVERE, WARNING). Following code sets up my test driver:

@RunOnHub
public abstract class SmokeTestCase extends ParallelTest {
    ...
        final ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.setHeadless(false);
        final LoggingPreferences logPrefs = new LoggingPreferences();
        logPrefs.enable(LogType.BROWSER, Level.ALL);
        chromeOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
        setDriver(new ChromeDriver(chromeOptions));
    ...

我的Vaadin应用程序在DEV模式下运行.使用以下代码,我试图通过测试驱动程序检索所有浏览器日志:

My Vaadin applications runs in DEV mode. With following code I'm trying to retreive all browser logs via the test driver:

final LogEntries entries = this.driver.manage().logs().get(LogType.BROWSER);
for (LogEntry entry: entries) {
  System.out.println(entry);
  final String line = String.format("[%s] - %s - %s", entry.getLevel().getName(), entry.getTimestamp(), entry.getMessage());
  if (entry.getLevel() == Level.SEVERE) {
    System.err.println(line);
  } else {
    System.out.println(line);
  }
}

很不幸,我只收到警告和严重警告.缺少INFO和TRACE.我在做什么错了?

Unfortunately, I only receive WARNING and SEVERE. INFO and TRACE are missing. What am I doing wrong?

我的方法与此类似:如何使用Selenium获取Chrome浏览器控制台日志[INFO]条目

我们还尝试启用和请求日志类型DRIVERCLIENT-但它们为空.

We also tried to enable and request the log types DRIVER or CLIENT - but they are empty.

Chrome驱动程序日志文件:

Chrome Driver log file:

[1563798293,491][INFO]: [9a5a5e7219d7e4e784ad1ccf205a31df] COMMAND GetLog {
   "type": "browser"
}
[1563798293,491][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=2292) 143AE946F7F1974C2722E6519DB6CBA5 {
   "expression": "1",
   "returnByValue": true
}
[1563798293,491][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=2292) 143AE946F7F1974C2722E6519DB6CBA5 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1563798293,491][INFO]: [9a5a5e7219d7e4e784ad1ccf205a31df] RESPONSE GetLog [ {
   "level": "SEVERE",
   "message": "http://.../APP/connector/0/443/icon/save-document_24.png - Failed to load resource: the server responded with a status of 410 ()",
   "source": "network",
   "timestamp": 1563798292695.0
}, {
   "level": "SEVERE",
   "message": "http://.../APP/connector/0/444/icon/container_3_24.png - Failed to load resource: the server responded with a status of 410 ()",
   "source": "network",
   "timestamp": 1563798292695.0
}, {
   "level": "WARNING",
   "message": "http://.../VAADIN/vaadinPush.js?v=8.7.2 0:40212 \"Websocket closed, reason: Normal closure; the connection successfully completed whatever purpose for which it was created. - w...",
   "source": "console-api",
   "timestamp": 1563798292711.0
}, {
   "level": "SEVERE",
   "message": "http://.../APP/connector/0/448/icon/save-document_24.png - Failed to load resource: the server responded with a status of 410 ()",
   "source": "network",
   "timestamp": 1563798292711.0
}, {
   "level": "WARNING",
   "message": "http://.../VAADIN/vaadinPush.js?v=8.7.2 0 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more...",
   "source": "deprecation",
   "timestamp": 1563798292776.0
} ]

推荐答案

自chromedriver 75.0.3770.8 CapabilityType.LOGGING_PREFS起已弃用.改为使用goog:loggingPrefs.

Since chromedriver 75.0.3770.8 CapabilityType.LOGGING_PREFS is deprecated. Use goog:loggingPrefs instead.

这篇关于Selenium Web驱动程序:提取的Chrome浏览器日志不完整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆