WebdriverIO:检索浏览器日志记录

Ewg*_*ski 5 logging selenium google-chrome webdriver-io

根据WebdriverIO-Dokumentation,我可以将浏览器控制台日志记录的输出集成到 webdriverio-logging 中。我的电话是然后browser.getLogs('browser')。但是,仅检索使用 console.warn() 发出的日志消息。所有 console.log() 消息都将被忽略。我如何管理它并将所有控制台消息包含到我的 webbriverio 报告中?

Rya*_*ton 2

如果您使用的是最新版本的 Chrome 并发现日志中只收到警告和错误消息,但您还需要 INFO,请将以下内容添加到您的wdio.conf.js

exports.config = {
  capabilities: [{
    ...
    "goog:loggingPrefs": {   // <-- Add this
      browser: "ALL",
    },
  }],
};
Run Code Online (Sandbox Code Playgroud)