【问题标题】:Fetch the value from the response data in Jmeter从 Jmeter 中的响应数据中获取值
【发布时间】:2021-02-13 18:19:59
【问题描述】:

这是我的回复数据,

{"system":false,"redirect":{"href":"\/\/localhost-933824.auth.org\/dashboard","data-loader":"fullscreen"},"name":false,"url":"login\/auth\/localhost","container":"#pyModule","scope":null,"infinite":false,"action":{"method":"update","target":"container"},"csrf":{"name":"csrf_token","value":"e18a9gbd853bda5c317cv48a3426y28e"}}

想要从响应中获取933824 值,如何在 Jmeter 中的任何提取器(如 regex 或 json)中执行此操作?我尝试使用 [^?]+(?:\?localhost-([^&]+).*)?/\?localhost-([a-z0-9\-]+)\&?/i 但没有工作。

【问题讨论】:

    标签: jmeter


    【解决方案1】:

    你把事情弄得太复杂了,\d meta character 代表“数字”,如果你添加一个代表“重复”的 + 符号,它将匹配任意数量的数字。

    因此,您可以将正则表达式简化为:

    localhost-(\d+).auth.org
    


    还要注意,还有更简单的方法:使用Boundary Extractor,您不必费心想出正确的正则表达式,您只需要提供“左”和“右”边界,它就会提取中间的所有内容:

    此外,这种方法消耗的资源更少,运行速度更快。更多信息:The Boundary Extractor vs. the Regular Expression Extractor in JMeter

    【讨论】:

      【解决方案2】:

      请在下面尝试,添加正则表达式提取器并提供以下表达式

      localhost-([^&]*).auth.org

      【讨论】:

        猜你喜欢
        • 2023-03-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-09-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多