嵌入式表达式不会在JSONPATH过滤器中替换

问题描述 投票:2回答:1

当我传递一个字符串的值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'

* callonce sleep 10

Given request ' '

当方法获得然后状态200 * def usernames = get response.integration.serviceData.record [*] .username * print usernames * print searchUser * def userNode = get [0] response.integration.serviceData.record [?(@。username =='#(searchUser)')] * print userNodeenter image description here

karate
1个回答
2
投票

嵌入式表达式仅适用于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 + "')]")
© www.soinside.com 2019 - 2024. All rights reserved.