量角器+混合角度1 + 2应用=失败 [英] Protractor + Hybrid Angular 1+2 Application = Fail

查看:126
本文介绍了量角器+混合角度1 + 2应用=失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

量角器在Angular 1上运行良好但在将我的应用程序升级为混合Angular 1 + 2后,我收到此错误:

Protractor works well on Angular 1 but after upgrading my app to an hybrid Angular 1+2 I get this error:


失败:等待量角器与页面同步时出错:
[ng:test]没有为getTestability找到元素参数的注入器
http://errors.angularjs.org/1.4.9/ng/test

当您没有ng-app标签< div ng-app = myAppManager> 时,这似乎是一个常见错误在你的Angular 1应用程序中,可以很容易地修复你的量角器配置文件中的 rootElement:'html',但它似乎没有改变混合应用程序的任何内容。

It seems a common error when you don't have a ng-app tag <div ng-app=myAppManager"> in your Angular 1 app and can be easily fixed wiyh rootElement : 'html' in your protractor config file but it doesn't seem to change anything on hybrid app.

我试过 rootElement:'html'甚至 useAllAngular2AppRoots:true

我怀疑问题来自异步加载混合角度(来自升级 doc):

I suspect the problem comes from the asynchronous loading of the hybrid angular (from the upgrade doc):


angular.bootstrap和
upgradeAdapter.bootstrap之间的一个值得注意的区别是后者异步工作。这个
意味着我们不能假设应用程序在引导程序调用返回后立即被实例化

One notable difference between angular.bootstrap and upgradeAdapter.bootstrap is that the latter works asynchronously. This means that we cannot assume that the application has been instantiated immediately after the bootstrap call returns.

我的配置文件:

exports.config = {
    framework: 'jasmine2',
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['protractor.js'],
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 50000,
    },
    allScriptsTimeout: 50000,//seb
    capabilities: {
        'browserName': 'chrome',
        'chromeOptions': {
            'prefs': {
                'profile.managed_default_content_settings.notifications':2
            }
        }
    },
    rootElement : 'html',
    // useAllAngular2AppRoots: true,
    jasmineNodeOpts: {
        realtimeFailure: true
    },
    onPrepare: function() {
      var failFast = require('jasmine-fail-fast');
      jasmine.getEnv().addReporter(failFast.init());
    }
}


推荐答案

量角器团队已经解决了这个问题:

Protractor team has fixed with this:

https ://github.com/angular/angular/pull/7603

编辑:我还没有测试过

编辑2:似乎不起作用,我回到angularJs(版本1)

这篇关于量角器+混合角度1 + 2应用=失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆