[英]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.