API自动化测试:是否可以通过内容验证来自动执行下载方案? [英] API Automation Testing : Is there any way to automate download scenario with content validation?

查看:63
本文介绍了API自动化测试:是否可以通过内容验证来自动执行下载方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我们的应用程序中具有Excel导出功能.对于这种情况,我有一种情况:

I have an export to excel feature in our application. For which I have one scenario:

  1. 执行导出至excel
  2. 验证API响应状态并导出excel内容.

使用Postman,我可以使用发送并下载"选项将导出的excel保存为.xlsx格式,稍后我将在该选项上手动验证内容(列标题和行值).

With Postman, I am able to save exported excel in .xlsx format with "Send and Download" option on which later I am validating content (Column Headers and row values) manually.

是否有任何方法可以通过API自动化来端到端地自动化此方案?

Is there any way to automate this scenario end to end through API automation?

当前,我正在执行get操作(空手道框架),它正在响应这些标头:

Currently, I am doing get operation (Karate framework) which is responding me these headers in response:

  1. 内容类型→application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

  1. Content-Type →application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

接受范围→字节

正文:流式传输人类不可读的对象.

Body: Stream objects which are not human readable.

状态:200 ok

如果无法实施e2e自动化,那么在这种情况下,自动化的接受标准应该是什么?

推荐答案

2个选项.

  1. 如果您确定文件的二进制内容不会改变,请执行二进制比较,请参见以下示例:您必须编写一些自定义代码.有用于读取Excel的Java库.使用其中之一,读取数据,然后与预期结果进行比较.请参阅Java interop上的文档并编写一个辅助函数来完成此操作.

    You have to write some custom code. There are Java libraries to read Excel. Use one of those, read the data, and then compare with expected results. Refer the docs on Java interop and write a helper function to do this.

    这篇关于API自动化测试:是否可以通过内容验证来自动执行下载方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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