使用 Protractor 检查 POST 请求有效负载数据 [英] Check POST request payload data with Protractor

查看:15
本文介绍了使用 Protractor 检查 POST 请求有效负载数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个带有几个输入元素和保存按钮的角度页面.单击保存按钮后,将发送 POST 请求.我正在为此页面编写 Protractor e2e 测试.

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 是一种工具,可帮助您通过自动化真实浏览器来模拟真实用户与页面的交互.它停留在高级别,查看普通用户可以看到的内容 - 单击按钮、填写输入等.

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.

仅供参考,有一个名为 protractor-http-mock 的相关工具 这可以帮助您测试极端情况,允许用自定义替换服务器响应.

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.

这篇关于使用 Protractor 检查 POST 请求有效负载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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