使用PhantomJS量角器错误 [英] Protractor error using PhantomJS

查看:179
本文介绍了使用PhantomJS量角器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用phantomJS和量角器运行我的角度页面上的端到端测试,由一饮而尽(标准角度发生器)产生的。 在等待量角器与网页同步错误:[NG:测试]当我要运行的第二个命令,我会收到以下错误没有注入发现元素参数getTestability ......


  • phantomjs --webdriver = 5000

  • 一饮而尽量角器

我已经看着它在互联网上,还对计算器,但它没有来解决。大家说,这是因为量角器找不到棱角页和我必须调整在protractor.conf.js的rootElement的选项。我试过了,但是这并没有为我工作了......有没有人有这个问题的解决方案?

这是我的protractor.conf.js

  exports.config = {
seleniumAddress:HTTP://本地主机:5000',
rootElement的:HTML,功能:{
    browserName:phantomjs',
    phantomjs.binary.path:C:/用户/..../ proj_Jesper2 / node_modules / phantomjs /斌/ phantomjs',
},规格:[paths.e2e +'/**/*.js'],框架:茉莉花,
//选项要传递给茉莉节点。
jasmineNodeOpts:{
    的onComplete:功能(){
    },
    isVerbose:真实,
    showColors:真实,
    includeStackTrace:真实,
    defaultTimeoutInterval:30000
}
};

这是index.html的角度页面:

 &LT;!DOCTYPE HTML&GT;&LT; HTML NG-应用=testJesper2&GT;&LT; HEAD&GT;&LT;间的charset =UTF-8&GT;&LT;标题&GT; testJesper2&LT; /标题&GT;&LT; META NAME =说明内容=&GT;&LT; META NAME =视口CONTENT =WIDTH =设备宽度&GT;&LT;链接rel =样式的href =风格/vendor-79b86c72.css\"><link的rel =stylesheet属性HREF =风格/ APP-56ebb463.css&GT;&LT; /头&GT;&LT;身体GT;&LT;! -  [如果LT IE 10] &GT;
&LT; p =类browsehappy&gt;您使用的是&LT;强&GT;&过时LT; / STRONG&GT;浏览器。请&lt; A HREF =htt​​p://browsehappy.com/&GT;升级浏览器&LT; / A&GT;改善您的体验与LT; / P&GT;
 &LT; ENDIF] - &GT;!&LT;格UI视图=&GT;&LT; / DIV&GT;&LT;脚本&GT;
      (功能(B,O,I,L,E,R){b.GoogleAnalyticsObject = L; B [L] ||(B [1] =
      功能(){(B [L] .Q = B [L] .Q || [])推(参数)}); B [L] .L = +新的日期;
      E = o.createElement(ⅰ); R = o.getElementsByTagName(ⅰ)[0];
      e.src ='// www.google-analytics.com/analytics.js';
      r.parentNode.insertBefore(E,R)}(窗,文件,'脚本','嘎'));
      GA('创造','UA-XXXXX-X'); GA(发送,浏览量);
    &LT; / SCRIPT&GT;&LT;脚本的src =脚本/供应商8ebd933c.js&GT;&LT; / SCRIPT&GT;&LT;脚本的src =脚本/ APP-a7333f52.js&GT;&LT; / SCRIPT&GT;&LT; /身体GT;&LT; / HTML&GT;


解决方案

问题解决了。当我与一饮而尽的工作,我忘了运行的搞砸了整个项目的单一命令一饮而尽服务是关键!

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>

解决方案

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!

这篇关于使用PhantomJS量角器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆