Search code examples
jmeterhref

How I can get a random value string in href by JSON Path Extractor with JMeter?


I have JSON responce

{
    "sessionName":"eL7tYgxhYh",
    "imageSrc":"/Common/CaptchaImage/**eL7tYgxhYh**?t=636573960197174426"
}

How I can get a random value string "eL7tYgxhYh" in href by JSON Path Extractor with JMeter?


Solution

  • You cannot achieve this using JSON Extractor as it can only deal with JSON Objects, i.e. you can easily get full value of the imageSrc attribute, but not more.

    I would recommend switching to Boundary Extractor instead, the relevant configuration would be something like:

    • Name of created variable: anything meaningful, i.e. href
    • Left Boundary: CaptchaImage/
    • Right Boundary: ?

    That's it, the "interesting" value should be now extracted and you should be able to refer it as ${href} where required

    Demo:

    JMeter Boundary Extractor Demo

    More information: The Boundary Extractor vs. the Regular Expression Extractor in JMeter