Kuldeep Yadav
Kuldeep Yadav

Reputation: 107

Stop While loop in jmeter when condition is true

My test plan structure is

Thread Group  
  --Http request    
while loop controller
  --http request
   --regular expression extractor (get a login config key which is used in while loop)

Regular expression:-"business_type":"(.+?)" variable name :-business_type while loop condition: :- ${__javaScript(("${business_type}" === "Apparel & Footwear" && ${counter} < 5),)

I want to stop while loop when the expected business type is found in response.

Upvotes: 0

Views: 1682

Answers (2)

Ori Marko
Ori Marko

Reputation: 58772

You need to check 2 condition while one for negative equal the string in While Controller:

${__jexl3(${counter} < 5 && "${business_type}" != "Apparel & Footwear")}

Prefer __jexl3 over __javascript function:

Checking this and using __jexl3 or __groovy function in Condition is advised for performances

Upvotes: 1

sunny_teo
sunny_teo

Reputation: 1999

Try using "!=" instead of "===". ${__javaScript("${business_type}" != "Apparel & Footwear" && ${counter} < 5)}

Upvotes: 0

Related Questions