JMeter Pre-Processors with Example

"Pre-Processors executes some action just prior to a sample being run".

A Pre-Processor elements is executed before the sampler and can be used for precondition setup. If a Pre-Processor is added to a test plan, then it will execute just before to that sampler element running. A Pre-Processor is most often used to adjust the settings of a Sample Request just before it runs.

Example: Say Suppose If we want to add something to the request just before sending it to the server we use pre-processor. It could be like fetching some information from Database or Regex operations. After performing some operations generate some input and pass these returned values to the request.

Here is a list of available Pre-Processors in JMeter:

  • Bean shell PreProcessor
  • BSF PreProcessor
  • JDBC PreProcessor
  • JSR223 PreProcessor
  • HTML link Parser
  • HTTP URL Re-writing Modifier
  • RegEx Users Parameters
  • Users Parameters
  • Sample Timeout

Let us now try to understand 'Users Parameters' pre-processor

"Users Parameters allows the user to specify values for User Variables specific to individual threads" . User Parameters Pre-Processor can be used to set different parameters for each simulated user. When only one user is defined, this value will be used for all threads.

Users Parameters Example:

Step 1: Test Plan > Add Thread Group
Set Number of Threads as: 2, ramp up period as: 1 and the loop count as: 1

Apache JMeter Timer

Step 2: Thread Group > Add > Config element > HTTP Request Defaults
Set Server Name or IP as: www.amazon.in

Step 3. Test Plan > Add > Pre Processor > User Parameters

1. Click 'Add User' at the bottom to add more user_2 (user_1 exist by default).
2. Click 'Add Variable' to add variable portion.
3. Click variable portion to enter data

Here we have added Name variable as Node_value, User_1 variable as 976392031 and User_2 variable as 1389401031 and check Update Once Per Iteration.

Apache JMeter Timer

Step 4: Thread Group > Add > Sampler > HTTP Request (rename it to Home Page)
Set Path as: /b/ref=nav_shopall_bty and add Parameter Name as: node, Value as: ${Node_value}

Apache JMeter Timer

Step 5: Thread Group > Add >Listener > View Results Tree

Step 6: Save and Run the Test Plan

Apache JMeter Timer

This will assign two different node to be used by each thread. The first node 976392031 is for Computers & Accessories and second node 1389401031 is for Mobile Phones categories respectively in www.amazon.in.

JMeter Tutorials: 

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.