请与量角器POST请求的有效载荷数据

问题描述:

让我们说我有一对夫妇投入要素的角度页并保存按钮。
保存按钮被点击后,POST请求将被发送。
我在写量角器端到端测试此页面。

Let's say i have angular page with a couple of input elements and save button. After Save button is clicked POST request will be sent. I'm writing Protractor e2e test for this page.

的问题:

我如何与量角器POST请求的有效载荷数据检查应用程序在发送前发出后,或?
我想确保我的应用程序将在POST请求发送正确的数据。

How can i check with protractor POST request payload data after app is sent it or before sending? I want to be sure that my app will sent right data in POST request.

继@Andres D的评论:是的,有一种误解,在这里

Following @Andres D's comment: yes, there is a misconception here.

量角器是一个工具,可以帮助您通过自动化真正的浏览器模仿与页面实际用户交互。它停留在高层次,所看到的普通用户可以看到 - 点击按钮,填写输入等。

protractor is a tool that helps you mimic real-user interactions with a page by automating a real browser. It stays on the high-level, sees what a normal user can see - click buttons, fills out inputs etc.

在换句话说,它是一种黑盒测试,也无所谓哪里是数据,该协议用于传送它还是多少外部JS文件的页面需要加载来临 - 这些都是技术细节应检查并分别进行测试。

In other words, it is a black box testing, it doesn't matter where is data coming from, which protocol used to transfer it or how many external js files your page requires to be loaded - these are all technical details that should checked and tested separately.

仅供参考,有一个名为 量角器-HTTP-模拟相关的工具 ,可以帮助你在测试边界情况允许与定义的自定义更换服务器的响应。

FYI, there is a relevant tool called protractor-http-mock that can help you in testing corner cases allowing to replace the server responses with custom defined.