Currently, I am conducting tests on Protractor for a website that is bootstrapping AngularJS manually. Despite the steps continuing to execute, I encounter this error:
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"
Upon visiting the link https://docs.angularjs.org/error/ng/test,
The explanation provided is as follows:
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.
This issue arises when transitioning from one Single Page Application (SPA) to another. Interestingly, the website under test does not utilize ng-app anywhere.
Based on my understanding, the root element for ng-app typically is html or body tag.
When utilizing body in my conf.js file, I can successfully run other tests. However, upon switching between SPAs, sometimes the aforementioned error occurs.
Below is an excerpt from my conf.js file:
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() {
}
};
Do I need to adjust the root element when navigating between different SPAs using spec files?
browser.rootElement
If anyone could provide guidance on this matter, would assigning an ID on top of the div where the SPA loads help resolve the issue?