zoukankan      html  css  js  c++  java
  • [Protractor] Use protractor to catch errors in the console

    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');
        });
      });
    });
  • 相关阅读:
    java多线程--线程和线程池
    java多线程--锁学习
    vue项目中使用iconfont
    组件封装-无数据组件
    添加自定义字体
    时间格式化(自定义格式)
    深度克隆方法
    LazyMan面试题
    lodash.throttle实现节流
    第6章:关系数据库理论(考研重点)
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5204269.html
Copyright © 2011-2022 走看看