EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Software Development Software Development Tutorials JMeter Tutorial JMeter While Controller
 

JMeter While Controller

Updated February 21, 2023

JMeter While Controller

 

 

Introduction to JMeter While Controller

JMeter provides a different controller for the user to perform load and performance testing per our requirements. The whole is one of the controllers that the JMeter provides. While the controller is used to run the child samplers from the Test Plan, it continues the execution until the condition is false from the condition field. For example, suppose the condition field has a blank value at that time while the controller exits. Normally the while controller is a conditional statement, and it allows us to implement some advanced scenario that means some condition depends on the other scripts.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

What is JMeter while controller?

Regarding building a high-level JMeter load test situation that accepts complex rationale, contingent upon specific conditions, it is sometimes expected to change the Sampler’s execution request. Typically JMeter runs every one of the Samplers topsy turvy, yet there could be a few situations when the default conduct isn’t reasonable.

JMeter’s execution of the while controller. For those inexperienced with the whole controller idea, to lay it out plainly, it’s simply a rehashed “if->then” articulation.

In the case something is valid, then, at that point, rehash the last activity

In JMeter, the regulator fundamentally runs kids Samplers, except if some foreordained “Condition” is “valid” where “Condition” could be:

Clear: for this situation, the While Controller will leave when the last sampler insider savvy falls flat

LAST: equivalent to clear, yet with an extra check for the last Sampler before the controller result. If the previous Sampler isn’t effective, the While Controller and its youngsters will not be executed.

Function or Variable JMeter: The Controller’s kids will run until a variable or capacity assessment result is “valid.”

Property of JMeter: equivalent to Function or Variable, yet expects the Property all things being equal

Both the Function/Variable and Property approaches expect that the “Condition” will be set to “bogus” someplace in or outside the controller. On account of Property, it very well may be done from another Thread Group or even external JMeter.

The initial 2 cases with “clear” and “LAST” are straightforward. Assuming you leave the “Condition” clear or set it to LAST, the controller will break if the last sampler under the While Controller isn’t fruitful. Similar applies to the Variables and Properties. The While Controller will control its youngsters until the Variable or Property determined in “Condition” will bring about “validity.”

How to use JMeter while controller?

Now let’s see how we can use the while controller in JMeter.

We know that while the controller runs the child until the condition is false.

First, we need to consider some possible conditions as follows.

Blank: Blank means it exits the loop when the last sample fails.

Last: means it exits the loop when the last sample fails.

Condition

The condition means variable or function, and while the controller requires true or false, that means, as per our requirement, we can set the condition.

First, create the Test Plan as per our requirement; here, we created the Test Plan as shown in the following screenshot.

JMeter While Controller output 1

Now add the Thread Group and sampler; here, we add the HTTP request sample as shown in the following screenshot.

JMeter While Controller output 2

Here we add a dummy API with a view result tree, as shown in the following screenshot.

JMeter While Controller output 3

As shown in the following condition, we must add the condition to implement the while controller.

JMeter While Controller output 4

First, while the controller, we can check with blank as shown in the following screenshot.

output 5

After executing the Test Plan, we can view the output in the view result tree, as shown in the following screenshot.

output 6

Now set the same condition as per our requirement; here, we set the counter value as follows.

${__javaScript(parseInt(vars.get(“counter”))<=50)}

After execution, we can set the result in the following screenshot.

output 7

output 8

Here we can access the dummy URL from the CSV file, which can be accessed through the variables.

JMeter while controller Functions

Now let’s see while the controller functions as follows.

We know JMeter provides the different types of inbuilt functions for the user to implement, while controller is as follows.

  1. Information

Under the information type, JMeter provides the different functions as follows.

  • thradNum: If we want to get the thread number, then we can use this number.
  • samplerName: It is used to get the name of a sampler.
  • Time: It returns the system’s current date per our required format.

As well as information type provides the log, logn, machinelp, and machineName functions.

  1. Input

Under the input type, JMeter provides different functions as follows.

  • StringFromFile: It is used to read the text from the file.
  • FileToString: If we require reading the entire file, we can use this function.
  • XPath: It is used to read the XPath expression from a file.
  • CSDVRead: It is used to read the CSV file.
  1. Calculation

Under calculation, JMeter provides the different types of functions as follows.

  • Counter: If we want to increment the number at that time, we can use this function.
  • intSum: It is used to add the integer to the number.
  • longSum: It is used to add the long integer number.
  • Random: By using this function, we can generate a random number.
  • RandomSring: By using this function, we can generate the random string.
  1. Scripting

Under scripting, JMeter provides the different types of functions as follows.

  • BeanShell: It is used to run the BeanShell script.
  • JavaScript: By using this function, we can work on JavaScript.

These are some sample types, and their function and JMeter also provide some additional functions such as Properties, Variables, String, etc.

JMeter while controller Cases

Now let’s see different cases for the while controller as follows.

  • While with counter: We can use a while controller to combine with a counter.
  • Sampler of Beanshell: Here, we can declare counter value 1.
  • While controller: We can check the counter value using the while controller.
  • Processor: It is used to increment the counter value.

Conclusion

We hope from this article you learn more about JMeter while controller.  From the above article, we have taken in the essential idea of JMeter while controller, and we also see the representation and example of the JMeter while controller. Furthermore, this article taught us how and when to use the JMeter while controller.

Recommended Articles

This is a guide to JMeter While Controller. Here we discuss the essential idea of JMeter while controller, and we also see the representation. You may also look at the following articles to learn more –

  1. Timers in JMeter
  2. What is JMeter?
  3. JMeter Interview Questions
  4. Manual Testing Tools

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW