首页 > 解决方案 > 如何在空手道的同一请求中传递表单数据文本和文件?

问题描述

我正在尝试对上传文件(图像、pdf)的 POST 请求进行测试。我的功能文件如下:

给定路径 'files' * multipart file fileUpl = { read: 'img1.jpeg', filename: 'img1.jpeg' } * multipart field destination = "posts" When method post Then status 200

文件被正确拾取,但没有拾取目标字段值。

回复:

混合:内容配置:表单数据;名称="文件上传"; 文件名="img1.jpeg" 内容类型:图像/jpeg;charset=UTF-8 内容长度:757770 已完成:true IsInMemory:false RealFile:/Users/deepanshu/Desktop/NoonCode/nimble/automation/target/test-classes/apiTests/files/img1.jpeg DefaultDeleteAfter:true

内容处置:表单数据;名称="目的地"; 文件名=“”内容类型:文本/纯文本;charset=UTF-8 内容长度:5 已完成:true IsInMemory:true

在上述情况下,我们如何传递具有值的字段。

标签: cucumberkarate

解决方案


推荐阅读