For any reason, there is an error in your code, maybe something like undefined error. Protractor still has all the test cases passing, but our application has some problem.

Or let's say in production code, we want check whether we have cleaned all of our console.log() code in the console.

To do that we can add an afertEach() block:

  afterEach(function () {
browser.manage().logs().get('browser').then(function (browserLog) {
expect(browserLog.length).toEqual(0);
if (browserLog.length) console.error('log: ' + JSON.stringify(browserLog));
});
});

----------------

Code:

var IndexPage = require('./IndexPage');

describe('hello-protractor', function () {

  var page = new IndexPage();

  beforeEach(function() {
page.get();
}); afterEach(function () {
browser.manage().logs().get('browser').then(function (browserLog) {
expect(browserLog.length).toEqual(0);
if (browserLog.length) console.error('log: ' + JSON.stringify(browserLog));
});
}); describe('index', function () {
it('should display the correct title', function () {
expect(page.getTitle()).toBe('hello protractor');
}); it('should display the message when button clicked', function () {
page.clickButton(); expect(page.getMessageText()).toBe('button 1 clicked');
});
});
});

[Protractor] Use protractor to catch errors in the console的更多相关文章

  1. log4j报错ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

    ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only err ...

  2. Angular+Grunt+Bower+Karma+Protractor (Atom)

    1. 配置bower 1.安装bower npm install -g bower 2.创建.bowerrc文件 { "directory": "src/bower&qu ...

  3. angular自动化测试--protractor

    前戏 面向模型编程: 测试驱动开发: 先保障交互逻辑,再调整细节.---by 雪狼. 为什么要自动化测试? 1,提高产出质量. 2,减少重构时的痛.反正我最近重构多了,痛苦经历多了. 3,便于新人接手 ...

  4. 自动化测试--protractor

    前戏 面向模型编程: 测试驱动开发: 先保障交互逻辑,再调整细节.---by 雪狼. 为什么要自动化测试? 1,提高产出质量. 2,减少重构时的痛.反正我最近重构多了,痛苦经历多了. 3,便于新人接手 ...

  5. debug protractor

    HTAir:protractor-cucumber-typescript kbladewht$ node --inspect-brk=0.0.0.0:1229 node_modules/protrac ...

  6. Node.js+Protractor+vscode搭建测试环境(1)

    1.protractor简介 官网地址:http://www.protractortest.org/ Protractor是一个end-to-end的测试框架,从网络上得到的答案是Protractor ...

  7. C++异常处理:try,catch,throw,finally的用法

    写在前面 所谓异常处理,即让一个程序运行时遇到自己无法处理的错误时抛出一个异常,希望调用者可以发现处理问题. 异常处理的基本思想是简化程序的错误代码,为程序键壮性提供一个标准检测机制. 也许我们已经使 ...

  8. C++异常处理: try,catch,throw,finally的用法

    写在前面 所谓异常处理,即让一个程序运行时遇到自己无法处理的错误时抛出一个异常,希望调用者可以发现处理问题. 异常处理的基本思想是简化程序的错误代码,为程序键壮性提供一个标准检测机制. 也许我们已经使 ...

  9. [Lua] try catch实现

    参考了https://blog.csdn.net/waruqi/article/details/53649634这里的代码,但实际使用时还有些问题,修改后在此记录一下. -- 异常捕获 functio ...

随机推荐

  1. 树状jquery导航条

    $(function () {        $(".leftsecoundtitle").css({ "display": "none" ...

  2. myeclipse10.7破解成功 但 无法打war包 securecrt alert:integrity check error 解决方案

    本次对于myeclipse10破解后,导出war包时报“SECURITY ALERT: INTEGERITY CHECK ERROR”进行了破解 只要执行完第一步的破解后,将com.genuitec. ...

  3. C#调用进程

    Process process = new Process(); process.StartInfo.FileName = "123.exe"; process.StartInfo ...

  4. OpenGL ES 2.0 雾

    在场景中使用雾不但可以提高真实感,特定的情况下还能优化性能.具体是指当物体离摄像机足够远时,雾就足够浓,此时只能看到雾而看不到物体,也就不必对物体着色进行详细计算,这样可以大大提高渲染效率. 雾有很多 ...

  5. Reverse digits of an integer.

    class Solution { public: int reverse(int x) { ;//long 是怕中间过程溢出 <<,max=-min-){ ans=ans*+x%; x=x ...

  6. JavaWeb学习笔记-使用HttpSession对象跟踪会话

    使用HttpSession接口开发的步骤: 1.获取HttpSession对象 2.对HttpSession对象进行读写 3.手工终止HttpSession,或者自动终止 常用方法: getId(): ...

  7. IOS 推送原理

    最近两天在研究ios的消息推送机制.研究这个东西,还是充满兴趣的. Push的原理: Push 的工作机制可以简单的概括为下图 图中,Provider是指某个iPhone软件的Push服务器,这篇文章 ...

  8. [OpenJudge] 百练2754 八皇后

    八皇后 Description 会下国际象棋的人都很清楚:皇后可以在横.竖.斜线上不限步数地吃掉其他棋子.如何将8个皇后放在棋盘上(有8 * 8个方格),使它们谁也不能被吃掉!这就是著名的八皇后问题. ...

  9. Effective Java2读书笔记-类和接口(五)

    第21条:用函数对象表示策略 这一条其实也没说啥,就是策略模式.碰到这种场景时,定义一个策略接口,然后不同策略子类实现它,主类包含这个接口的引用就可以了. 第22条:优先考虑静态成员类 嵌套类是指被定 ...

  10. 解决PopupWindow遮住输入法

    1: PopupWindow中的设置 pop.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); pop.setSoftInputMode(Win ...