简体   繁体   English

Selenium Web Driver:提取的 Chrome 浏览器日志不完整

[英]Selenium Web Driver: Extracted Chrome Browser logs are incomplete

I'm writing browser tests for a Vaadin application with help of Selenium.我正在 Selenium 的帮助下为 Vaadin 应用程序编写浏览器测试。 The Chrome browser log console in development utilities shows logs of different log levels (TRACE, SEVERE, WARNING).开发实用程序中的 Chrome 浏览器日志控制台显示不同日志级别(跟踪、严重、警告)的日志。 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));
    ...

My Vaadin applications runs in DEV mode.我的 Vaadin 应用程序在 DEV 模式下运行。 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);
  }
}

Unfortunately, I only receive WARNING and SEVERE.不幸的是,我只收到警告和严重。 INFO and TRACE are missing.缺少信息和跟踪。 What am I doing wrong?我究竟做错了什么?

My approach is simular to this one: How to get Chrome browser console log [INFO] entries with Selenium我的方法与此类似: 如何使用 Selenium 获取 Chrome 浏览器控制台日志 [INFO] 条目

We also tried to enable and request the log types DRIVER or CLIENT - but they are empty.我们还尝试启用和请求日志类型DRIVERCLIENT - 但它们是空的。

Chrome Driver log file: Chrome 驱动程序日志文件:

[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
} ]

Since chromedriver 75.0.3770.8 CapabilityType.LOGGING_PREFS is deprecated.由于 chromedriver 75.0.3770.8 CapabilityType.LOGGING_PREFS已弃用。 Use goog:loggingPrefs instead.请改用goog:loggingPrefs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用selenium web驱动程序加载chrome浏览器的问题 - Problems with loading chrome browser using selenium web driver 如何在不将IE驱动程序或Chrome驱动程序添加到硒Web驱动程序的情况下启动已安装的浏览器? - How can I start installed browser without adding IE driver or Chrome driver in selenium web driver? 使用Selenium驱动程序调用Chrome浏览器时出现问题 - Issue while invoking chrome browser with Selenium Driver 如何将硒Web驱动程序用于所有浏览器-chrome,safari,firefox,IE(JAVA) - How to use selenium web driver for all browser-chrome,safari,firefox,IE(JAVA) Selenium Chrome驱动程序限制网络刮痧规模 - Selenium Chrome Driver Limitations Web Scraping at Scale 使用selenium web驱动程序复制浏览器会话 - replicate browser session with selenium web driver 如何将Tor浏览器用作Web驱动程序硒? - How to use the tor browser as web driver selenium? 本地连接问题Selenium Web驱动程序和chrome驱动程序 - local connection issue selenium web driver with chrome driver 如何使用Selenium Web驱动程序来引用Web浏览器的运行实例? - How to use selenium web driver to refer to the running instance of web browser? 无法在Selenium网络驱动程序(Java)中启动Chrome - Unable to start Chrome in Selenium Web-driver (Java)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM