【发布时间】:2015-06-17 03:42:13
【问题描述】:
我正在量角器上运行测试。我正在测试手动引导 angularjs 的网站。在运行测试时,这是我得到的错误,即使步骤继续执行
Error while waiting for Protractor to sync with the page:
"[ng:test] no injector found for element argument to getTestability
\nhttp://errors.angularjs.org/1.3.15/ng/test"
转到链接 https://docs.angularjs.org/error/ng/test
我得到的解释是这样的
Angular's testability helper, getTestability, requires a root
element to be passed in. This helps differentiate between different
Angular apps on the same page.
This error is thrown when no injector is found for root element.
It is often because the root element is outside of the ng-app.
当我从一个 SPA 切换到另一个 SPA 时出现此错误。我正在测试的网站在任何地方都没有使用 ng-app。
据我了解,ng-app 的根元素通常是 html 或 body
如果我在我的 conf.js 中使用 body。我能够成功运行其他测试,但是当我从一个 SPA 导航到另一个 SPA 时,测试有时会出现上述错误
这是我的 conf.js 文件
var customReport = require('./Utilities/HtmlWriter.js').htmlWriter;
//config dependencies - all the js files in tests folder ending with -spec.js will be executed
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub', //Selenium webdriver instance needed to run the tsts
specs: ['./tests/functional/EditAppInfo_spec.js'], // All tests need to be placed inside tests folder and should end with _spec.js
baseUrl:'http://url.in.test.net',
capabilities: {
'browserName': 'firefox',
},
/*
multiCapabilities:[
{
'browserName': 'chrome'
},
{
'browserName': 'firefox'
},
{
'browserName': 'internet explorer',
}
],
*/
getPageTimeout:30000,
allScriptsTimeout:30000,
rootElement: "body",
jasmineNodeOpts: {
onComplete: null,
isVerbose: true,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 10000000000000
},
onPrepare: function() {
}
};
当我在不同的 SPA 之间导航时,是否需要更改根元素?
browser.rootElement
谁能帮我解决这个问题。如果我让开发人员在加载 SPA 的 div 顶部放置一个 ID,这会解决吗?
【问题讨论】:
标签: javascript angularjs protractor