I have test case in my csv file. The request URL has a custom variable.
Sample URL : .../abc/$id
I need to replace this id
by the id
that we get in response from the previous request. I used json extractor to fetch the id
from the response. Now I need to update this id
in the next test case request. Fetched the Request URL from jmeter context using below code:
String path = ctx.getCurrentSampler().toString();
path.replaceAll("$id", id);
I am not able to set this updated URL in jmeter context (ctx
)
path
variableSo you need to amend your code like:
String path = ctx.getCurrentSampler().toString();
path = path.replaceAll("$id", id);
sampler.setPath(path);
Demo:
Also consider switching to JSR223 PreProcessor and Groovy language as Groovy performance is much higher, it better supports new Java features and provides some extra "syntax sugar" on top. See Groovy is the New Black article for details.