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');
        });
      });
    });
  • 相关阅读:
    基础架构:一条SQL查询语句是如何执行的?
    常用的字符串转换日期格式
    JSONObject.fromObject(map)(JSON与JAVA数据的转换)
    ModelAndView的介绍
    Springmvc常用注解
    @PathVariable注解
    @ModelAttribute运用详解
    struts2将servlet对象注入到Action中
    为什么要继承ActionSupport?
    mysql中like用法
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5204269.html
Copyright © 2011-2022 走看看