当我传递一个字符串的值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 * print routevalue * cookie route = routevalue * string searchUser ='anupama'
当方法获得然后状态200 * def usernames = get response.integration.serviceData.record [*] .username * print usernames * print searchUser * def userNode = get [0] response.integration.serviceData.record [?(@。username =='#(searchUser)')] * print userNode
嵌入式表达式仅适用于JSONPath和XML:https://github.com/intuit/karate#embedded-expressions
请使用karate
API进行动态JsonPath:https://github.com/intuit/karate#jsonpath-filters
* def userNode = karate.jsonPath(response, "$.integration.serviceData.record[?(@.username=='" + searchUser + "')]")