Search code examples
jmeter

How do I reference a variable within the Jmeter User Defined Variable control?


I'm currently creating a test suite of API tests in JMETER. I've created a "User Defined Variable" config element to help parameterize the tests. The value goes into the "Path" of the API request. However.....

When I input
NAME: dev.testAppUrl
VALUE: https://devurl/api/applications/${ID}

the test returns an error because its treating ${ID} as a literal string in the URL path.
If the url is hardcoded in the test request it works fine to leave the ${ID} in there and that value is scraped from a previous request using a "regular expression extractor control" and populated as expected, but I would love to not hardcode these path values.


Solution

  • You should use eval function to get the ${ID} replaced at run time.

    ${__eval(${dev.testAppUrl})}