[英]How to pass multiple parameters in post request in karate framework?
I have a JSON data file which has data like我有一个 JSON 数据文件,其中包含类似的数据
{
"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.首先,我想读取这些数据,当 Wheels.value == Yes 时,我想点击一个 API,否则点击另一个 API 另外,我想知道如何在 post 请求或文件中传递多个参数。
Post request data is as follows: post请求数据如下:
title:Alloy_wheel__Info
part:acCooling
partTitle:AC Cooling
partValue:No
Above data i'm passing through "form-data" in postman.
以上数据我正在邮递员中通过“表单数据”。
Thanks in advance提前致谢
Your question is hard to understand and I will assume that you want to loop over some given JSON array and do some actions.你的问题很难理解,我假设你想遍历一些给定的 JSON 数组并执行一些操作。 Sounds like you are not "testing" and mis-using Karate !
听起来你不是在“测试”和误用空手道!
To loop over a JSON array, use call
.要遍历 JSON 数组,请使用
call
。 Refer the docs: https://github.com/intuit/karate#data-driven-features请参阅文档: https : //github.com/intuit/karate#data-driven-features
To do conditionals, read this part of the documentation: https://github.com/intuit/karate#conditional-logic要做条件,请阅读文档的这一部分: https : //github.com/intuit/karate#conditional-logic
To do "form-data" read this: https://github.com/intuit/karate#form-field要执行“表单数据”,请阅读: 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')
How to implement api1.feature
and api2.feature
is a homework for you.如何实现
api1.feature
和api2.feature
是你的功课。 Keep in mind that in both you will still have access to the data
variable.请记住,在两者中您仍然可以访问
data
变量。 And please read the docs and examples !请阅读文档和示例!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.