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');
});
});
});

最新文章

  1. 2016 ACM/ICPC Asia Regional Dalian Online 1008 Function 二分+RMQ
  2. 读书笔记——body and html
  3. Win7 Print Spooler服務自动关闭
  4. ios view的frame和bounds之区别(位置和大小)
  5. Qt 5 在Windows下 出现QApplication: No such file or directory 问题的解决办法
  6. oracle-12c-rac 报:ORA-01078
  7. 改变SQL默认数据库的存储路径
  8. thinkphp多表查询
  9. 初识markdown以及markdown的常用语法
  10. DDD理论学习系列(6)-- 实体
  11. JS变量重复声明以及忽略var 声明的问题及其背后的原理
  12. 20款最好的JavaScript开发框架
  13. redis-py说明文件(转)
  14. tag标签数据库的设计
  15. 利用JS 在网页上获取并显示当前日期 星期
  16. MySQL中报错: [Err] 1146 - Table 'performance_schema.session_status' doesn't exist 解决办法
  17. webpack4基本配置
  18. TerminateProcess
  19. 【luogu P3608 [USACO17JAN]Balanced Photo平衡的照片】 题解
  20. IntelliJ IDEA设置鼠标移动到方法上提示API注释

热门文章

  1. Java学习笔记——JDBC之与数据库MySQL的连接以及增删改查等操作
  2. (转)WCF中调用WebService出错,大家帮忙看看,回答就有分
  3. ps 换图片的背景颜色
  4. HDU 3966 dfs序+LCA+树状数组
  5. 手把手教你如何使用webpack+react
  6. kafka相关应用
  7. 函数:灵活即强大 - 零基础入门学习Python018
  8. Linux 结束占用端口的程序
  9. POJ 3675 Telescope
  10. DataGrid导出excel