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');
        });
      });
    });
  • 相关阅读:
    clipboard复制剪贴板功能,以及用sea.js时报错---Uncaught ReferenceError: Clipboard is not defined
    关于字体跨域
    关于 sass
    移动端返回上一页
    第二次结对编程作业
    第一次结对编程作业
    第一次个人编程作业
    软工实践第一次作业
    XGB算法梳理
    GBDT算法梳理
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5204269.html
Copyright © 2011-2022 走看看