I am getting an error which reads:
"Error while waiting for Protractor to synce with the page: "Cannot read property '$$testability' of undefined"
Below is my test.
describe('On the MyMoments page', function(){
beforeEach(function() {
var editLocationText = 'Location';
browser.driver.get('http://192.168.0.6:8100/#/page1/myMoments');
});
it('The edit button should work', function() {
browser.driver.get('http://192.168.0.6:8100/#/page1/myMoments').then(function() {
// browser.waitForAngular();
browser.getCurrentUrl().then(function(url) {
});
});
});
});
This is my config file:
exports.config = {
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
args: ['--disable-web-security']
}
},
baseUrl: 'http://192.168.0.6:8100',
specs: [
'*.test.js'
],
jasmineNodeOpts: {
isVerbose: true,
}
};
I don't think this is something to do with my test since my test is incredibly simple. Has anybody run into this issue before? I'm a bit stuck.
Thanks.
EDIT:
Downgraded my Protractor version all the way to 4.0.14 in order to fix this error. Now i'm getting:
"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.5.3/ng/test"
If anyone knows what this is or how to resolve this, let me know!
Thanks.
This is a known issue in Protractor, see here. As mentioned in the issue this is because browser.angularAppRoot() is expected to return the current value of app root if a value isn't passed to it, but currently returns undefined.
A new release is coming that should fix this issue.
Hope it helps
Changing the browser from chrome to firefox worked for me.
// conf.js
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'firefox'
},
specs: ['login-spec.js']
}
Although it's sometimes caused by documents without an html tag in the root, "Cannot read property '$$testability' of undefined" is more likely to manifest as a symptom of another error that prevented the page from loading, or any interaction with a page that isn't loaded for whatever reason.
Try using a browser.sleep above the line that is throwing the error, to give the page time to load.
A browser.ExpectedConditions clause which is intended to wait for a specific condition can throw this error if the page is not ready for protractor.
Sometimes, hard coded sleeps can not be avoided.
To diagnose and fix it,
- Place browser.enterRepl(); into the code just before the line
that seems to be throwing the $$testability error.
- If the $$testability error still gets thrown, then move browser.enterRepl(); up a few lines
- Each time enterRepl() gets triggered without the $$testability error, then move browser.enterRepl(); down one line
- Finally, when enterRepl is moved to the line directly below the line causing the error, you may now see a different error message which is more meaningful.
- Place a browser.sleep() or other code to fix your specific issue just prior to the line causing that error.
I had the same issue with an Angular hybrid app.
In my case the issue was fixed after removing,
rootElement: 'myRootElement'
from the config.