当我传递字符串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'
方法获得时 然后状态200 * def用户名=获取response.integration.serviceData.record [*]。用户名 *打印用户名 *打印searchUser * def userNode = get [0] response.integration.serviceData.record [?(@。username =='#(searchUser)')] *打印userNode
答案 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 + "')]")