Embedded expressions are not replaced in the JSONPATH filter

徘徊边缘 提交于 2020-11-29 10:03:58

问题


When i am passing the value of a string json filter is working fine. But when I am passing embedded expression in the JSONPATH it is not replacing actual value.

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'

And header X-CSRF-TOKEN = csrfToken * cookie JSESSIONID = jsessionid * print routevalue * cookie route = routevalue * string searchUser = 'anupama'

* callonce sleep 10

Given request ' '

When method get Then status 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


回答1:


Embedded expressions are only for JSONPath and XML: https://github.com/intuit/karate#embedded-expressions

Please use the karate API for dynamic JsonPath: https://github.com/intuit/karate#jsonpath-filters

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


来源:https://stackoverflow.com/questions/52218765/embedded-expressions-are-not-replaced-in-the-jsonpath-filter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!