Apache JMeter Correlation Using the CSS/JQuery Extractor in JMeter


Example

The CSS/JQuery extractor enables extracting values from a server response by using a CSS/JQuery selector syntax, which might have otherwise been difficult to write using Regular Expression. As a post-processor, this element should be executed to extract the requested nodes, text or attribute values from a request sampler, and to store the result into the given variable. This component is very similar to the XPath Extractor. The choice between CSS, JQuery or XPath usually depends on user preference, but it’s worth mentioning that XPath or JQuery can traverse down and also traverse up the DOM, while CSS can not walk up the DOM. Let’s assume that we want to extract all the topics from the Stack Overflow documentation that are related to Java. You can use the Firebug plugin to test your CSS/JQuery selectors in Firefox, or the CSS Selector Tester in Chrome.

enter image description here

To use this component, open the JMeter menu and: Add -> Post Processors -> CSS/JQuery Extractor

enter image description here

Almost all of this extractor’s fields are similar to the Regular Expression extractor fields, so you can get their description from that example. One difference however is the “CSS/JQuery Extractor implementation” field. Since JMeter 2.9 you can use the CSS/JQuery extractor based on two different implementations: the jsoup implementation (detailed description of its syntax here) or the JODD Lagarto (detailed syntax can be found here). Both implementations are almost the same and have only small syntax differences. The choice between them is based on user’s preference.

enter image description here

Based on the above mentioned configuration, we can extract all the topics from the requested page and verify the extracted results by using the “Debug Sampler” and the “View Results Tree” listener.