在角量角器茉莉花测试中查看 console.log 输出 [英] view console.log output in angular protractor jasmine test

查看:16
本文介绍了在角量角器茉莉花测试中查看 console.log 输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 angularjs 量角器 jasmine 测试中查看 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 步.我正在尝试将 e2e 测试更改为量角器.我使用的量角器配置文件基于 %appdata% pm ode_modulesprotractor eferenceConf.js.在配置文件引用的规范 js 文件中,我有 console.log 的实例.然而,在量角器 e2e 测试执行期间,网站以 chrome 打开,我看到浏览器中发生了一些事情,然后浏览器在我检查任何 console.log 输出之前关闭.我想我需要以某种方式保持 chrome 打开.怎么样?

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% pm ode_modulesprotractor eferenceConf.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().logs().get('browser')

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 输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆