JSONPATH过滤器中未替换嵌入式表达式

时间:2018-09-07 08:46:27

标签: karate

当我传递字符串json过滤器的值时,它工作正常。但是,当我在JSONPATH中传递嵌入式表达式时,它并不能替代实际值。

Given url appServer +'/integration/rest/user'+'?page=0'+'&pageSize=10'+'&fieldList=first_name,last_name,id,username,last_login,active,date_created'+'&filter=user_type%20equals%20%27P%27%20'+'&getTotalRecordCount=true'

头X-CSRF-TOKEN = csrfToken * cookie JSESSIONID = jsessionid *打印路线值 * Cookie路线=路线值 *字符串searchUser ='anupama'

* callonce睡眠10

给出请求''

方法获得时 然后状态200 * def用户名=获取response.integration.serviceData.record [*]。用户名 *打印用户名 *打印searchUser * def userNode = get [0] response.integration.serviceData.record [?(@。username =='#(searchUser)')] *打印userNode enter image description here

1 个答案:

答案 0 :(得分:2)

嵌入式表达式仅适用于JSONPath和XML:https://github.com/intuit/karate#embedded-expressions

请为动态JsonPath使用karate API:https://github.com/intuit/karate#jsonpath-filters

* def userNode = karate.jsonPath(response, "$.integration.serviceData.record[?(@.username=='" + searchUser + "')]")