api - How to pass multiple parameters in post request in karate framework?
问题描述
I have a JSON data file which has data like
{
"Status": "Pending",
"role": "manager",
"client": "android",
"user": "test@abc.com",
"eTyres":
{
"Wheels": {
"title": "Alloy Wheel",
"value": "Yes"
}
}
}
Firstly, I want to read this data and when Wheels.value == Yes then I want to hit an API else hit another API Also, I would like to know how i can pass multiple parameters in post request or from the file.
Post request data is as follows:
title:Alloy_wheel__Info
part:acCooling
partTitle:AC Cooling
partValue:No
Above data i'm passing through "form-data" in postman.
Thanks in advance
解决方案
你的问题很难理解,我假设你想遍历一些给定的 JSON 数组并做一些动作。听起来您不是在“测试”和误用空手道!
要遍历 JSON 数组,请使用call
. 参考文档:https ://github.com/intuit/karate#data-driven-features
要执行条件,请阅读文档的这一部分:https ://github.com/intuit/karate#conditional-logic
要执行“表单数据”,请阅读:https ://github.com/intuit/karate#form-field
* def data = { "Status": "Pending", "role": "manager", "client": "android", "user": "test@abc.com", "eTyres": { "Wheels": { "title": "Alloy Wheel", "value": "Yes" } } }
* eval data.eTyres.Wheels.value == 'Yes' ? karate.call('api1.feature') : karate.call('api2.feature')
如何实施api1.feature
,api2.feature
是你的功课。请记住,在这两种情况下,您仍然可以访问该data
变量。请阅读文档和示例!
推荐阅读
- ios - SwiftUI 中的 TabView 不会改变视图
- python - Python 3.4 语法错误以及如何修复它
- python - Python:围绕圆圈放置的文本的旋转值
- sql - 将数据库 1 中的一个表更新为数据库 2 中的一个表接收转换数据错误
- flutter - 如何使用 multi_image_picker: ^4.6.7 和 Dio 上传多张图片?
- python - 将 2D 灰度重塑为 4D 以进行 Keras 模型推理
- php - SELECT count(*) from where date(week number) 等于当前周数
- javascript - Node Express 中的全局变量和类文件中的访问
- oracle - 为什么 AFTER UPDATE (FOR EACH ROW) 触发器在 (NOT DEFERRABLE) 完整性约束检查之前触发?
- python - 尝试并行运行 sklearn KMeans 的多个实例