【问题标题】:Protractor. Browser error after one action on the page量角器。页面上的一项操作后出现浏览器错误
【发布时间】:2017-09-10 02:07:02
【问题描述】:

我是量角器的新手,现在我的工作需要为 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();

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

提前谢谢你。

【问题讨论】:

  • 在规范中发布您的登录代码,以便我们知道发生了什么...
  • 是的,登录代码已添加到帖子中。

标签: angularjs webdriver protractor


【解决方案1】:

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

我建议仅作为临时解决方案来禁用量角器的 waitForAngular 来调试您的测试:

browser.waitForAngularEnabled(false)

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

但我 99% 确信这是必须在前端解决的问题,以便通过自动等待角度实现平滑的测试自动化。

更新:您也可以尝试在量角器配置中打开此属性 - https://github.com/angular/protractor/blob/master/lib/config.ts#L485

【讨论】:

    猜你喜欢
    • 2019-08-16
    • 1970-01-01
    • 2015-12-23
    • 1970-01-01
    • 2014-05-26
    • 1970-01-01
    • 2014-04-08
    • 2014-04-13
    • 2020-12-12
    相关资源
    最近更新 更多