用量角器与PhantomJS [英] Using Protractor with PhantomJS

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

问题描述

我需要端到端的测试我的AngularJS应用的量角器好像做了正确的方式。设置是相当简单,它就像在Chrome浏览器的魅力。我需要使用,无论无头的浏览器,并在研究如何使用量角器与PhantomJS,我发现这一点:


  

请注意:我们不推荐使用PhantomJS与量角器测试。
  没有与PhantomJS崩溃和行为许多报告的问题
  不同于真正的浏览器。


以上是从 https://github.com/angular /protractor/blob/master/docs/browser-setup.md

所以我的问题是:


  1. 这仍然是这样和Proractor仍然有PhantomJS问题?


  2. 如果这样怎么坏它,有没有更好的选择吗?


  3. 我会怎么做时,我的应用程序部署到服务器的端到端测试?



解决方案

  

这仍然是这样和量角器仍然有PhantomJS问题?


这是非常真实的。


  

如果这样怎么坏它,有没有更好的选择?


这是很难回答的是多么糟糕,但大约有挂phantomjs,奄奄一息phantomjs,执行缓慢phantomjs例如多个问题:

据的问题,你用量角器的主要原因是终端到终端的测试。你应该试着去模仿真实世界的使用案例,模拟真实用户在应用程序中工作。的将一个真实的用户使用什么浏览器? PhantomJS?答案很可能是不。的使用您的应用程序的设计工作中的浏览器,以及您的真实用户使用浏览器。


  我

会怎么做端到端测试时,我的应用程序部署到服务器?


最自然的方法是使用的远程服务器硒的,提供不同的功能 - 浏览器和平台。您可以启动和配置自己的服务器硒,或者您可以使用 BrowserStack 酱实验室 这是做的非常出色,提供你一个方法来测试中各种不同的浏览器和系统的应用程序。

您也可以运行在一个无头的环境,没有真正的量角器,但虚拟显示( xvfb的),看到更多的这里

I need to E2E test my AngularJS Application an Protractor seems like the right way to do it. Setup was fairly straightforward and it works like a charm in Chrome. I need however use headless browser and been researching on how to use Protractor with PhantomJS and I found this:

Note: We recommend against using PhantomJS for tests with Protractor. There are many reported issues with PhantomJS crashing and behaving differently from real browsers.

Above is from https://github.com/angular/protractor/blob/master/docs/browser-setup.md

So my questions are:

  1. Is this still the case and Proractor still having issues with PhantomJS?

  2. If so how bad is it and is there any better option?

  3. How would I do E2E testing when my app is being deployed to server?

解决方案

Is this still the case and Protractor still having issues with PhantomJS?

This is very true.

If so how bad is it and is there any better option?

It's difficult to answer how bad is it, but there are multiple issues about hanging phantomjs, dying phantomjs, performing slow phantomjs e.g.:

According to the question, the main reason for you to use protractor is end-to-end testing. You should try to imitate real-world use cases, imitate a real user working in your application. What browser would a real user use? PhantomJS? The answer is probably "no". Use the browsers which your application is designed to work in, and the browsers your real users use.

How would I do E2E testing when my app is being deployed to server?

The most "natural" approach is to use a remote selenium server that provides different capabilities - browsers and platforms. You can start up and configure your own selenium server, or you can use BrowserStack or Sauce Labs which are doing a great job providing you a way to test your application among a wide variety of different browsers and systems.

You can also run protractor in a headless "environment" with no real, but virtual display (xvfb), see more here.

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

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