使用 PhantomJS 的量角器错误

Protractor error using PhantomJS

我正在使用 phantomJS 和量角器来 运行 我的 angular 页面上的 e2e 测试,由 gulp(标准 angular-生成器)生成。当我想 运行 第二个命令时,我会收到以下错误:"error while waiting for Protractor to sync with the page: "[ng:test] 没有找到用于 getTestability 的元素参数的注入器..."

网上已经查过了,Whosebug也查过了,但是没有解决。大家都说是protractor找不到angular页面,我要调整protractor.conf.js里面的rootelement-option。我试过了,但这对我没有用...有人有解决这个问题的方法吗?

这是我的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
}
};

这是 index.html angular 页面:

<!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>

问题已解决。当我在使用 gulp 时,我忘记了 运行 一个命令,它搞砸了整个项目...... "gulp serve" 是关键!