In this JMeter Tutorial, you will learn about Post Processor in JMeter, Just to make it simple to understand, we should understand that post processor is simple element of JMeter’, which runs only after request is sent to the server and response is received by the client from the server, as a result of the request sent.
Many times we have seen the situation when we have to extract some particular value from the response coming from the server. Now let us consider a scenario we are sending a request to the web server and if we are getting error in the response.
Now we want that when we get error in the response from the server, then we should stop the test execution. For handling such scenario in JMeter, we use
Post processor available in JMeter. One thing we should understand is that for adding post processor, first of all we will need to create Thread Group inside Test Plan and then we need to create Sampler inside the Thread Group and then only we can add Post Processor.
Because we know that when we have to do some operation after getting the response, then only we can use Post processor. Therefore for having response from the web server we need to have Sampler element inside the Thread Group.
Sampler is nothing but the request that is sent to the server to get expected response from the server. We can see it in the following screenshot. Also, we can see various types of post processor are available in JMeter.
- BeanShell Postprocessor
- BSF Postprocessor
- CSS/JQuery Extractor
- Debug Postprocessor
- JDBC Postprocessor
- JSON Path Postprocessor
- JSR223 Postprocessor
- Regular Expression Extractor
- Result Status Action Handler
- XPath Extractor
Regular Expression Extractor
Regular expression Extractor is one of the most commonly used Post Processor in JMeter. Load testing professionals who have worked on LoadRunner should be having idea of correlation in LoadRunner.
There are many inbuilt facility provided by LoadRunner, which makes the work of correlation very easy in LoadRunner, same correlation is done through Postprocessorin JMeter.
For beginners we do not need to understand what correlation is, at this stage. I have just added the concept to make it simple for LoadRunner professionals who want to understand JMeter, I have used the term here.
Though do not have knowledge of LoadRunner suit ignored the term at the moment. Now let us understand why to use Regular Expression Extractor in JMeter and how we use it .
After sending request to server multiple times, we understand one particular template/pattern which some dynamic variables (which changes each time request is made to server) like session variables follow and in order to generalize that pattern, so that we can make large number of request to the web server for large number of users .
What happens is that regular expression extractor extracts the desired value and stores that value in a variable.
XPath Extractor
Many times we have to find and extract content from XML structure or XHTML structure in which we get in the form of response from the server.
It is not so easy and when we have to find content that particular location in the XML structure, first of all, we need to identify its position in the XML structure and once we identify the position of the content in the XML structure, we may define its Xpath.
Xpath in nothing but the position of the content in the XML structure. Those Who Are having knowledge of selenium automation testing should be having idea of Xpath which Automation Testing professional use for identifying element in the HTML structure of web page on which element is located. the main thing.
It is the xpath mechanism which helps in proper navigation and extracts text from the response which may be in the form of XML or XHTML. We should have little understanding of Xpath to use these processor
Result Status Action Handler
As we have already discussed, there are situations when we get error response from the web server.
After sending the request and we want test to be stopped, if there is error in the response coming from the web server, in such situations, we should have some mechanism to stop the test.
Result Status Action Handler element comes to rescue in such situations and help us to stop the thread or the test if there is no proper response from the server.
We can see from the screenshot given above that we are available with the following choices when we have to deal with the situation when there is a problem with the sampler or the response coming from the server.
The possible choices which are available in this post-processor are Continue, Start next thread loop, Stop Thread, Stop Test and Stop Test Now. Let us look at them one by one to understand clearly.
Continue – It means that we have to simply ignore the error and continue with the test.
Start next thread loop – It means that it will stop the execution of sample when there is error found in the current simpler but it will continue the execution for next iteration.
Stop Thread – It means that execution of current thread will stop.
Stop Test – It means that entire test will be stopped when there is error in any of sample are found but it will attitude the current sample execute the current employer sample offer simple art
Stop Test Now – It will stop the entire test abruptly. It does not allowed the current employer to complete
Now that we have seen how Post processors are used in JMeter. It is very simple to use. The only thing we should understand is how to use it and how to work on response data.
Post processors are mainly used to capture particular content data from the response coming from the server, which will be used later on for any other purposes.