Protractor 在 Angular 1 上运行良好,但在将我的应用程序升级到混合 Angular 1+2 后,我收到此错误:
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"
当您没有 ng-app 标签时,这似乎是一个常见错误 <div ng-app=myAppManager">
在您的 Angular 1 应用程序中,可以轻松修复 rootElement : 'html'
在你的 Protractor 配置文件中,但它似乎没有改变混合应用程序上的任何内容。
我试过了 rootElement : 'html'
甚至 useAllAngular2AppRoots: true
.
我怀疑问题出在混合 Angular 异步加载(来自 upgrade 文档):
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 团队已解决此问题:
https://github.com/angular/angular/pull/7603
编辑:我还没有测试过
编辑 2:似乎不起作用,我又回到了 angularJs(版本 1)
编辑 3:我转向 React
关于javascript - Protractor + 混合 Angular 1+2 应用 = 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35435080/