JMeter – BeanShell PreProcessor

BeanShell PreProcessor is a scripting-based PreProcessor in JMeter. It means that you can implement the preprocessor logic by yourself using one of the supported scripting languages. Usually, it is helpful when you need to define logic based on your requirement and want to write some unique algorithm which is not currently provided by JMeter. You can implement your own algorithm using BeanShell PreProcessor.

How to add ‘BeanShell PreProcessor’ in JMeter?

Follow the below steps to add ‘BeanShell PreProcessor’:

  1. Select the appropriate element where you want to add PreProcessor
    1. Test Plan
    2. Thread Group
    3. Logic Controller
    4. Sampler
  2. Right-click on the element
  3. Hover the mouse on ‘Add’
  4. Hover the mouse on ‘PreProcessor’
  5. Click ‘BeanShell PreProcessor’
JMeter - BeanShell PreProcessor
Figure 01

What are the input fields?

‘BeanShell PreProcessor’ has the following inputs:

  1. Name: To provide the name of the timer
  2. Comments: To provide arbitrary comments (if any)
  3. Reset bsh.Interpreter before each call: Interpreter will be recreated by selecting the value of this option as ‘Yes’. 
  4. Parameters: Parameters to pass to the BeanShell script. This is an optional attribute.  
  5. Script file: A file containing the BeanShell script to run. The return value is used as a preprocessor output generated by BeanShell script.
  6. Script: The BeanShell script which contains the PreProcessor Logic.

You may be interested: