我尝试在空手道测试中使用 JsonPath 过滤器表达式的 RHS 中的变量,类似于:
* def name = 'A Name'
* def ids = $response[?(@.name == '#(name)')].id
如果我使用文字字符串'A Name'
在表达式的右侧,它按预期工作。
我尝试了各种方法来评估变量:'<name>'
, "#(name)"
, etc.
我怀疑这是因为我将 JsonPath 解析与空手道解析混合在一起?
首先阅读此内容:https://github.com/intuit/karate#rules-for-embedded-expressions
您正在寻找的是这样的:https://github.com/intuit/karate#jsonpath-filters
* def ids = karate.jsonPath(response, "$.kittens[?(@.name=='" + name + "')].id")
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)