In case you have worked with JMeter scripts before, you must have stuck at some point and find yourself asking “How do I debug this stuff?”, “Why is my regular expression or jsonpath not working?” Actually, there are many ways to debug JMeter scripts and it’s very easy.
Here are some ways to debug a JMeter script.
1.View Result Tree
JMeter has various listener types. View Result Tree is the one that should be used to debug any request. It allows you to debug Jsonpath, XML or a Regular expression by its user interface. It can be added to your JMeter script through right-click menu: Add > Listener > View Results Tree.
After executing any scripts, you can go into your “View Result Tree” and select the debug type. There are many different types for that.
In that screen you see the content of your request, response and sampler itself with the headers, status code etc. Also as default, Debugging option “Text” is selected on the left hand side of the screen. When you open ‘Response Data’ you will be able to search for any textual or numeric value in the response as “Text” is selected.
But you might need to search something from a JSON or XML response. In those cases, listener allows you to choose “CSS Selector Tester”, “JSON Path Tester” or “XML Path Tester”.
So you can right your queries and validate if they are working fine or not.
Here’s another example with Regular Expression Tester.
Using that listener is efficient than modifying an already existing script and playing once again till you find the right selector or values.
Not: While executing your performance test, don’t forget to disable View Tree Listener as it stores everything in the memory and it will crash your execution by consuming the memory.