问题描述
我如何可以查看在angularjs量角器茉莉测试的console.log输出?截至目前,浏览器本身关闭速度太快了。
How can I view console.log output in an angularjs protractor jasmine test? As of now, the browser closes by itself too quickly.
更多信息 - 我与angularjs教程的学习,第8步。我试图端到端测试改为量角器。我用量角器配置文件是基于%APPDATA%\\故宫\\ node_modules \\量角器\\ referenceConf.js。在由配置文件中引用的规范js文件,我的console.log的实例。然而,量角器端到端测试的执行过程中,该网站在Chrome中打开,我看到的东西在浏览器中发生,那么在浏览器关闭之前,我可以检查任何的console.log输出。我想,我需要保持开放的铬莫名其妙。怎么样?
more info - I am working with the angularjs tutorial, step 8. I am trying to change the e2e test to protractor. The protractor config file I'm using is based on %appdata%\npm\node_modules\protractor\referenceConf.js. In spec js files referenced by the config file, I have instances of console.log. However, during execution of the protractor e2e test, the web site opens in chrome, I see things happen in the browser, then the browser closes before I can examine any console.log output. I think I need to keep chrome open somehow. How?
推荐答案
使用 browser.manage()日志()得到('浏览器')
browser.manage().logs().get('browser').then(function(browserLogs) {
// browserLogs is an array of objects with level and message fields
browserLogs.forEach(function(log){
if (log.level.value > 900) { // it's an error log
console.log('Browser console error!');
console.log(log.message);
}
});
});
这篇关于查看角量角器茉莉测试的console.log输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!