You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JMeter:当响应匹配指定业务类型时停止While循环的实现咨询

Alright, let's break down exactly how to structure your JMeter test plan with all the configurations you specified. Here's a clear, step-by-step breakdown:

JMeter Test Plan Structure & Key Configurations

Hierarchical Component Layout

  • Thread Group
    • HTTP Request (your initial pre-loop request)
    • While Loop Controller
      • HTTP Request (the request you want to repeat in the loop)
      • Regular Expression Extractor (captures the value needed for loop termination logic)

Critical Configuration Details

Regular Expression Extractor Setup

  • Regular Expression: "business_type":"(.+?)"
  • Reference Name (Variable Name): business_type
  • Match No.: 1 (grabs the first matching result from the response)

While Loop Controller Termination Condition

Use JMeter's built-in __javaScript function to define when the loop stops. Paste this into the "Condition (function or variable)" field:

${__javaScript(("${business_type}" === "Apparel &amp; Footwear" && ${counter} < 5),)}

Quick note: Make sure you've added a Counter element to your test plan to initialize and increment the ${counter} variable with each loop iteration. This condition will exit the loop either when the matched business_type equals your target value or when the counter hits 5—whichever comes first.

How It All Works

  1. The Thread Group kicks off, running the initial HTTP request first
  2. The While Loop Controller starts, executing the nested HTTP request
  3. The Regular Expression Extractor pulls the business_type value from the request's response
  4. The loop checks the condition: if the business type matches your expected value and the counter is under 5, it repeats; if either condition fails, the loop terminates

内容的提问来源于stack exchange,提问作者Kuldeep Yadav

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 07:40:25