【问题标题】:Embedded expressions are not replaced in the JSONPATH filterJSONPATH 过滤器中的嵌入表达式不会被替换
【发布时间】:2021-03-03 12:20:08
【问题描述】:

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

* callonce sleep 10

给定请求“”

当方法获取时 然后状态 200 * def usernames = 获取 response.integration.serviceData.record[*].username * 打印用户名 * 打印搜索用户 * def userNode = get[0] response.integration.serviceData.record[?(@.username== '#(searchUser)')] * 打印 userNode

【问题讨论】:

    标签: karate


    【解决方案1】:

    嵌入式表达式仅适用于 JSONPath 和 XML:https://github.com/intuit/karate#embedded-expressions

    请使用karate动态JsonPath API:https://github.com/intuit/karate#jsonpath-filters

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多