嵌入式表达式不会在 JSONPATH 过滤器中被替换
Embedded expressions are not replaced in the JSONPATH filter
当我传递一个字符串的值时 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'
和header X-CSRF-TOKEN = csrfToken
* cookie JSESSIONID = jsessionid
* 打印路由值
* cookie 路由 = 路由值
* 字符串搜索用户 = 'anupama'
* callonce 睡眠 10
给定请求“”
方法获取时
然后状态200
* def usernames = get response.integration.serviceData.record[*].username
* 打印用户名
* 打印搜索用户
* def userNode = get[0] response.integration.serviceData.record[?(@.username== '#(searchUser)')]
* 打印用户节点
嵌入式表达式仅适用于 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 + "')]")
当我传递一个字符串的值时 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'
和header X-CSRF-TOKEN = csrfToken * cookie JSESSIONID = jsessionid * 打印路由值 * cookie 路由 = 路由值 * 字符串搜索用户 = 'anupama'
* callonce 睡眠 10
给定请求“”
方法获取时
然后状态200
* def usernames = get response.integration.serviceData.record[*].username
* 打印用户名
* 打印搜索用户
* def userNode = get[0] response.integration.serviceData.record[?(@.username== '#(searchUser)')]
* 打印用户节点
嵌入式表达式仅适用于 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 + "')]")