Protractor 在 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:
失败:等待 Protractor 与页面同步时出错:"[ng:test] 没有为 getTestability 的元素参数找到注入器http://errors.angularjs.org/1.4.9/ng/test"
Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability http://errors.angularjs.org/1.4.9/ng/test"
当您的 Angular 1 应用程序中没有 ng-app 标签 <div ng-app=myAppManager">
并且可以轻松修复时,这似乎是一个常见错误wiyh 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
.
我怀疑问题来自混合 Angular 的异步加载(来自 升级文档):
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 团队已经解决了这个问题:
Protractor team has fixed with this:
https://github.com/angular/angular/pull/7603
我还没有测试过
编辑 2:似乎不起作用,我回到了 angularJs(版本 1)
编辑 3:我移至 React
这篇关于量角器 + 混合 Angular 1+2 应用程序 = 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!