JMeter – Elements

JMeter - Elements

YouTube Video: Apache JMeter – Elements (A Glance)

JMeter is an easy-to-operate tool with a simple UI. Basically, it is an element based tool which has separate elements for all the script building operations like think time, response check, request, cache, test scenario etc. As per your need, you can add JMeter elements and perform the test. Because of its element-based feature, many external plug-ins are available which help to make scripting and analysis part easy. So, let’s try to understand what are all the elements of Apache JMeter.

When you launch JMeter in GUI mode, you can see a default element i.e. Test Plan. Rest other elements need to be added as per the requiment.

There are total 11 elements in JMeter which are:

Description of JMeter Elements:

  1. Test Plan: Test Plan is a Parent element under which the other JMeter elements are added. It is a default element. You can rename the test plan as per your project name or test case name.
  2. Thread Group: A Thread Group defines a pool of users that execute a particular test case as per your SLA. In the Thread Group GUI, you can control the number of simulated users (threads), the ramp-up time (how long it takes to start all the threads), the number of times to perform the test and optionally, the duration and start-up delay for the test.
  3. Logic Controllers: Logic Controllers determine the execution order of the sampler or other child elements. 
  4. Samplers: Samplers allow JMeter to send specific types of requests to a server. They simulate a user request for a page from the target server. It is a kind of request generator (of the specific type) which server can understand. In Micro Focus LoadRunner term you can call it ‘Protocol’.
  5. Config Elements: Configuration elements are useful to activate the initial set-up at the start of any test. During test initialization, respective values are assigned to or by them. They are used to set up defaults and variables which are used by Samplers and other elements during the test.
    Note that config elements are scope specific. They are processed before any samplers in the same scope and limited to use only for those samplers; cannot be accessed by out-side Samplers. Config element can be global or local.
  6. Pre-processors: A pre-processor element runs just before a sampler executes. They are often used to modify the settings of a Sample Request just before it runs, or to update variables that are not extracted from response text.
  7. Post-processors: A post-processor executes after a sampler finishes its execution. This element is useful to process the response data. The most important Postprocessor is Regular Expression Extractor.
  8. Assertions: Assertions helps to identify the correctness of server response. You can use them to run against a sample and its subsamples to ensure returned values match expected results or not. JMeter highlights Sampler in RED (in ‘View Tree Result’ Listener) when an assertion fails.
  9. Timers: Timer is used to control the rate of request hitting to the server. JMeter thread sends requests without pausing between each sampler. Timers allow JMeter to delay between each request which a thread makes. A timer can solve the server overload problem. You can add a timer element which allows you to define a period to wait between each request.
  10. Listener: A listener is a component that shows the results of the samples. Listener allows you to view and analyze the Sampler request and response in the form of tables, graphs, trees etc. You can also save results in a file and read saved results later. You can access the sampler result in an ongoing load/stress test without waiting until the test is completed (only in GUI mode). The listener can be global or local.
  11. Non-Test Elements: These elements do not directly participate in the test execution, but have a significant contribution to JMeter scripting. HTTP(S) Test Script Recorder specially used to record the test script.

Mostly, JMeter elements are scope specific and hence you need to add them in the script logically. Some of the elements can be a parent as well as child element for others, but some element do not follow the hierarchy like ‘Timer’ does not have any child element.

To understand and remember the parent-child relationship of JMeter element, refer to this article JMeter Element Relationship.


Leave a Reply

Your email address will not be published. Required fields are marked *