将量角器与 PhantomJS 一起使用

2023-06-15前端开发问题
3

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

问题描述

我需要对我的 AngularJS 应用程序进行 E2E 测试,Protractor 似乎是正确的方法.设置相当简单,它就像 Chrome 中的魅力一样.但是我需要使用无头浏览器并一直在研究如何将 Protractor 与 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 有时会崩溃(开放问题超过一年)
  • 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 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

Fatal error: Call to a member function fetch_assoc() on a no
业务场景:使用update语句去更新数据库字段。 原因:update接收值不正确。原来代码: $query = "UPDATE student SET date = now() WHERE id = $id";$result = $mysqli-query($query2) or die($mysqli-error); // 问题出现了在这句 $data = $result-fetch_ass...
2024-12-13 前端开发问题
136

layui实现laydate日历控件控制之前日期不可选择
具体实现代码如下: laydate.render({ elem: '#start_time', min:0, //,type: 'date' //默认,可不填}); 只要加一个min参数,就可以控制了。0表示之前的日期不可...
2024-11-29 前端开发问题
133

如何使用百度地图API获取地理位置信息
首先,我们需要在百度地图开放平台上申请一个开发者账号,并创建一个应用。在创建应用的过程中,我们会得到一个密钥(ak),这是调用API的凭证。 接下来,我们需要准备一个PHP文件,以便可以在网页中调用。首先,我们需要引入百度地图API的JS文件,代码如下...
2024-11-22 前端开发问题
244

ajax请求获取json数据并处理的实例代码
ajax请求获取json数据并处理的实例代码 $.ajax({ type: 'GET', url: 'https://localhost:44369/UserInfo/EditUserJson',//请求数据 data: json,//传递数据 //dataType:'json/text',//预计服务器返回的类型 timeout: 3000,//请求超时的时间 //回调函数传参 suc...
2024-11-22 前端开发问题
215

js删除数组中指定元素的5种方法
在JavaScript中,我们有多种方法可以删除数组中的指定元素。以下给出了5种常见的方法并提供了相应的代码示例: 1.使用splice()方法: let array = [0, 1, 2, 3, 4, 5];let index = array.indexOf(2);if (index -1) { array.splice(index, 1);}// array = [0,...
2024-11-22 前端开发问题
182

layui 实现实时刷新一个外部的div
主页面上显示了一个合计,在删除和增加的时候需要更改这个总套数的值: //html代码div class="layui-inline layui-show-xs-block" style="margin-left: 10px" id="sumDiv"spanSOP合计:/spanspan${totalNum}/spanspan套/span/div 于是在我们删除这个条数据后,...
2024-11-14 前端开发问题
156