I\'m using jMeter to test a Tomcat application. I need to parse the jMeter response and make a second request. The first response looks like this:
To capture part of the response use Regular Expression Extractor.
You can test your regex expression on response data using ViewResultsTree listener. Just select Regexp tester in the drop-down box at the bottom of the left hand panel in your ViewResultsTree listener.
Ok so you already know how to extract url out of your response, I described how in my previous answer :
https://stackoverflow.com/a/11188349/169277
But here I'll just expand on that. So you have your sampler and you already got ${url}
. Now you need FILELIST
and assemble new url.
Assuming you already have request and url extractor in place. Add a new Regular expression extractor
.
Right click on request sampler -> Post Processors -> Regular Expression Extractor
Reference Name : FILELIST
Regular Expression : FILELIST=(\S+)
Template : $1$
Match No. (0 for Random): 1
So now you have 1 request sampler and 2 regular expression extractors. You need to add additional post processor to be able to assemble the new url.
Right click on request sampler -> Post Processors -> BSF PostProcessor
Choose the beanshell
from the language droplist under the Script language
and in the big field Script:
paste this :
vars.put("NEW_URL", "${__javaScript('${url}'.replace('
'\,'${FILELIST}'))}");
And now you have ${NEW_URL}
to use further in your tests.
There is always more than one way of solving problems, this one liner looks really ugly but it serves the purpose.
In my test the result is as you requested (Debug Sampler) :
url=https://192.168.100.46/updserver/download?action=signature_download&token=
FILELIST=1555;1340778737370;1526545487;
NEW_URL=https://192.168.100.46/updserver/download?action=signature_download&token=1555;1340778737370;1526545487;
EDIT :
I think I don't understand how you name your variables. But the end result is the one you described in your question. Please see the .jmx test attached with working example :
http://www.filefactory.com/file/1q7nfitmh4qd/n/so_11309469_jmx
It's a jmeter .jmx file working with 2.6+ version of jmeter