在 PhantomJS 中使用量角器 [英] Using Protractor with PhantomJS

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

问题描述

我需要 E2E 测试我的 AngularJS 应用程序,量角器似乎是正确的方法.设置相当简单,它在 Chrome 中就像一个魅力.然而,我需要使用无头浏览器,并一直在研究如何在 PhantomJS 中使用量角器,我发现了这一点:

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:

注意:我们不建议使用 PhantomJS 进行 Protractor 测试.有许多报告的 PhantomJS 崩溃和行为问题与真实浏览器不同.

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

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

所以我的问题是:

  1. 情况是否仍然如此,Proractor 是否仍然存在 PhantomJS 的问题?

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

如果是这样,情况有多糟糕,还有更好的选择吗?

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

当我的应用程序部署到服务器时,我将如何进行 E2E 测试?

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

推荐答案

情况是否仍然如此,Protractor 仍然对 PhantomJS 有问题?

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

这是非常正确的.

如果是这样,情况有多糟糕,还有更好的选择吗?

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

很难回答它有多糟糕,但是有很多关于挂 phantomjs、死亡 phantomjs、执行慢 phantomjs 的问题,例如:

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

  • PhantomJS sometimes crashes (open issue for more than a year)

根据问题,您使用 protractor 的主要原因是端到端测试.您应该尝试模仿真实世界的用例,模仿在您的应用程序中工作的真实用户.真正的用户会使用什么浏览器?幻影JS?答案可能是否定的. 使用您的应用程序设计用于工作的浏览器,以及您的真实用户使用的浏览器.

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.

当我的应用程序部署到服务器时,我将如何进行 E2E 测试?

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

最自然"的方法是使用远程 selenium 服务器,它提供不同的功能 - 浏览器和平台.您可以启动和配置自己的 selenium 服务器,也可以使用 BrowserStackSauce Labs 做得很好,为您提供了一种在广泛范围内测试您的应用程序的方法各种不同的浏览器和系统.

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.

您还可以在没有真实但虚拟显示的无头环境"中运行量角器 (xvfb),请参阅更多此处.

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

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

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