How can I extract all values of a property in JMeter?

In JMeter, you can use either the regular expression extractor or JSON extractor to extract all values of a property.

  1. Regular expression extractor:
  2. Include an HTTP request to access the target webpage or API endpoint.
  3. Add a regular expression extractor as a child node of the HTTP request to select the response field where the desired attribute is located (such as the response body or response header).
  4. In the “regular expression” field, write a regular expression to match all the attribute values that need to be extracted. Use parentheses to group them for extraction.
  5. In the “template” field, use the values of reference groups such as $1$, $2$, etc. If multiple attributes need to be extracted, they can be separated by commas, like $1$, $2$.
  6. In the “Match case” field, select “Extract all matching items” to extract all attribute values.
  7. You can use the “Debug Sampler” to view the extracted property values.
  8. JSON extractor:
  9. Include an HTTP request to access the target webpage or API interface.
  10. Add a JSON extractor as a subnode of the HTTP request. Select the response field (such as response body) where the desired property needs to be extracted.
  11. Enter the appropriate JSON path expression in the “JSON Path Expression” field to match all the necessary attribute values for extraction.
  12. Enter a variable name in the “Variable Name” field to store the extracted attribute value.
  13. You can use the “Debug Sampler” to view the extracted property values.

Both methods can be used to extract all values of a property. The specific method to use depends on the response format of the target webpage or API interface.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds