Pre-Processor element is defined to alter the settings of Samplers in their scope. It will always execute before the actual sampler request.
Pre-Processors elements list is as follows:
- BeanShell PreProcessor
- BSF PreProcessor
- HTML Link Parser
- HTTP URL Re-writting Modifier
- JDBC PreProcessor
- JSR223 PreProcessor
- RegEx User Parameters
- Sample Timeout
- User Parameters
Let’s have a look on some common types of Pre-processors:
1: User Parameters:
User Parameter element is used to define variables and its values, specific to individual threads.
User Parameter values will be defined for the current sampler only, unlike User Defined Variables in test plan which are available to all the samplers in the scope.
- Update Once Per Iteration Checkbox: A flag to specify whether the User Parameters element should update its variables only once per iteration.
- Add Variable: New empty row can be added to define variable
- Add User: New column can be added for user/thread
2: HTML Link Parser:
HTML Link Parser is used to parse HTML response from the test server and to extract links/forms.
If we use this preprocessor with a sampler, that URL test sample will be examined to see if it matches any of the links/forms which extracted from the previous response. If this is the case then it will replace the URL test sample values from the matching link/form.
3: HTTP URL Re-writing Modifier:
HTTP URL Re-writing Modifier is quite similar to the “HTML Link Parser”. However, it is more efficient and easy to use because it has a specific goal to achieve. For Instance: If your web application uses URL rewriting to store session Ids instead of cookies, you can define this element at the Thread Group level similar to the HTTP Cookie Manager. You are required to mention Session Id parameter name, then it will find it on the page and will pass argument to every request of that Thread Group.
- Session Argument parameter name is used to fetch value (href/form) from previous response.
- If you web application rewrite URLs by appending a semi-colon and session Id parameter, then select it.
- If your web application rewrite URLs without an "=" sign between parameter name and its value, then select it.
- It will prevent query string in the path extension.
- Check "Cache Session Id" checkbox, if session Id is to be saved for later use, when there is no session Id present.
- URL Encode value while writing parameter.
4: RegEx User Parameters
RegEx User Parameters element let us stipulate dynamic values for HTTP parameters extracted from other HTTP Request with the help of Regular Expressions. RegEx User Parameter are specific to individual threads in a test plan.