简体   繁体   English

如何在运行 webdriver io v7 (javascript) 测试时从浏览器控制台捕获错误日志

[英]How to capture error logs from browser console while running test for webdriver io v7 (javascript)

So browser.getLogs() is deprecated which was in package JsonWireProtocol which is replaced by WebDriver protocol.因此 browser.getLogs() 被弃用,它在 package JsonWireProtocol 中被 WebDriver 协议取代。 I want to capture browser logs (Error and warnings) when the test shows the reports, I cant find something similar in the docs, but I found a command called addConsoleLogs( https://webdriver.io/docs/spec-reporter/#addconsolelogs ),if someone has a running example to show would be great.我想在测试显示报告时捕获浏览器日志(错误和警告),我在文档中找不到类似的东西,但我找到了一个名为 addConsoleLogs( https://webdriver.io/docs/spec-reporter/# addconsolelogs ),如果有人有一个正在运行的例子来展示会很棒。 Thank you (using webdriver io v7) I have already tried browser.getLogs() but no luck so looking forward to other approaches with an example.谢谢(使用 webdriver io v7)我已经尝试过 browser.getLogs() 但没有运气所以期待其他方法的例子。

On your wdio.conf.js add the following configuration:在你的wdio.conf.js添加以下配置:

reporters: [
  [
    'spec',
      {
        addConsoleLogs: true,
      },
  ], 
]

Then on your test you can add a console.log add see logs on terminal.然后在您的测试中,您可以添加一个console.log add see logs on terminal。

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

相关问题 使用水豚捕获浏览器控制台日志 - Capture browser console logs with capybara 如何在 Angular 的 chrome 浏览器中捕获控制台日志 - How do I capture console logs in chrome browser in Angular 如何从浏览器中检索旧的控制台日志? - How to retrieve old console logs from browser? 尝试从v7迁移到Bing Maps v8时出错 - Error trying to migrate to Bing Maps v8 from v7 Google Drive Node.js-从节点v7更新到v9后上传文件时出错 - Google Drive Node.js - error while uploading files after update from node v7 to v9 使用SeleniumWebDriver时无法捕获浏览器控制台日志 - Unable to capture browser console logs when using SeleniumWebDriver 如何使用Karma单元测试运行器捕获console.error? - How to capture console.error with Karma unit test runner? 如何从赛普拉斯测试运行程序和控制台日志中禁用阻塞主机 URL? - How to disable blockedHosts urls from Cypress test runner and console logs? 柴将错误记录到控制台而不是未通过测试 - Chai logs error into console instead of failing the test Chrome扩展程序未在Selenium Javascript Webdriver测试中运行 - Chrome Extension Not Running in Selenium Javascript Webdriver Test
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM