2017-04-13 25 views
0

我是量角器的新手,现在我的工作需求是为angularjs应用程序创建测试项目。 我已经开始与指导方针和开始面临着错误:量角器。在页面上执行一个动作后浏览器出错

Error: Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! 
Watchers fired in the last 5 iterations: [] 
http://errors.angularjs.org/1.4.0/$rootScope/infdig?p0=10&p1=%5B%5D 
http://localhost/main-f3fbd0c72e8415cd0a449214b66bdacc-cached.js:2140 
    at window.onerror (http://localhost/main-f3fbd0c72e8415cd0a449214b66bdacc-cached.js:1277:52) 

配置文件

exports.config = { 
    directConnect: true, 

    seleniumAddress: 'http://localhost:4444/wd/hub', 

    capabilities: { 
     'browserName': 'chrome' 
    }, 
    specs: ['specs/spec.js'], 

    jasmineNodeOpts: { 
     showColors: true, 
     defaultTimeoutInterval: 30000 
    } 
}; 

测试文件:

"use strict"; 

    describe('WEB test project', function() { 

    var wl5StartPage = require('../pages/startPage.js'); 
     it('Its start login page', function() { 
     wl5StartPage.get(); 
     wl5StartPage.wl5Login(); 
    }); 
    }); 

startPage.js:

var WL5LoginPage = function() { 

    this.userName = element(by.model('loginInfo.userId')); 
    this.loginButton = element(by.css('[ng-click="login()"]')); 

    this.get = function() { 
     browser.get('http://localhost/login'); 
    }; 

    this.wl5Login = function() {  
     this.userName.sendKeys("user1"); 
     this.loginButton.click(); 
    }; 
} 

module.exports = new WL5LoginPage(); 

它非常简单的测试,但不幸的是,当我输入用户名并点击“登录”时它崩溃了。 有没有办法忽略这种浏览器错误?或者以某种方式解决问题?

预先感谢您。

+1

发布您的登录代码的规范里面,这样我们就知道是怎么回事... –

+0

当然可以,登录码添加到帖子。 –

回答

0

基本上量角器JS代码没有问题。你看到这个的原因 - 这是因为你的角度应用程序会抛出这个错误。量角器试图等待页面上的角度 - 但不能。好像你的错误是与此类似 - Error: 10 $digest() iterations reached. Aborting! with dynamic sortby predicate

我建议只作为临时解决方案禁用量角器的waitForAngular只是为了调试测试:

browser.waitForAngularEnabled(false)

http://www.protractortest.org/#/api?view=ProtractorBrowser.prototype.waitForAngularEnabled

但我99%肯定,这是前端必须解决的问题,以实现平稳的自动测试和自动等待角度。

UPDATE:另外你可以尝试在你的量角器config来打开这个属性 - https://github.com/angular/protractor/blob/master/lib/config.ts#L485

相关问题