使用“$.[:2]”运算符获取少量元素会在空手道中引发错误。可能是一个错误
Fetching few elements using "$.[:2]" operator throws error in karate. might be a bug
Example:
Scenario: test
* def response =
"""
[
"YEN01",
"DP258",
"SA661",
"BT202",
"UR809"
]
"""
* def subset = response.[:2]
* print subset
我试过回应..[:2]。并尝试用 () 括起来。
如果有人成功了,请告诉我。
只需添加一个字符即可解决您的问题!
* def subset = $response.[:2]
空手道默认为 JavaScript,当您需要 JsonPath 评估时,您需要给空手道一点提示。这在文档中有解释:https://github.com/intuit/karate#get-short-cut
Example:
Scenario: test
* def response =
"""
[
"YEN01",
"DP258",
"SA661",
"BT202",
"UR809"
]
"""
* def subset = response.[:2]
* print subset
我试过回应..[:2]。并尝试用 () 括起来。 如果有人成功了,请告诉我。
只需添加一个字符即可解决您的问题!
* def subset = $response.[:2]
空手道默认为 JavaScript,当您需要 JsonPath 评估时,您需要给空手道一点提示。这在文档中有解释:https://github.com/intuit/karate#get-short-cut