问题
I'm using phantomJS and protractor to run an e2e-test on my angular page, generated by gulp (standard angular-generator). When I want to run the second command, I will get the following error: "error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability..."
- phantomjs --webdriver=5000
- gulp protractor
I already looked it up on the internet, also on stackoverflow, but it didn't come to a solution. Everyone says it's because protractor can't find the angular page and that I have to adjust the rootelement-option in the protractor.conf.js. I tried that, but that didn't work out for me... Does anyone has a solution for this problem?
This is my protractor.conf.js
exports.config = {
seleniumAddress: 'http://localhost:5000',
rootElement: 'html',
capabilities: {
browserName: 'phantomjs',
'phantomjs.binary.path': 'C:/Users/..../proj_Jesper2/node_modules/phantomjs/bin/phantomjs',
},
specs: [paths.e2e + '/**/*.js'],
framework: 'jasmine',
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
onComplete: function () {
},
isVerbose: true,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 30000
}
};
This is the index.html angular page:
<!doctype html><html ng-app="testJesper2"><head><meta charset="utf-8"><title>testJesper2</title><meta name="description" content=""><meta name="viewport" content="width=device-width"><link rel="stylesheet" href="styles/vendor-79b86c72.css"><link rel="stylesheet" href="styles/app-56ebb463.css"></head><body><!--[if lt IE 10]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]--><div ui-view=""></div><script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
ga('create','UA-XXXXX-X');ga('send','pageview');
</script><script src="scripts/vendor-8ebd933c.js"></script><script src="scripts/app-a7333f52.js"></script></body></html>
回答1:
Problem solved. As I was working with gulp, I forgot to run a single command which screwed up the whole project... "gulp serve" was the key!
来源:https://stackoverflow.com/questions/29407750/protractor-error-using-phantomjs