Currently developing a script in jMeter, I need to retrieve x amount of values from a response then push those values into another HTTP request, here is the tricky part the response is a table which always changes (e.g. rows increase or decrease each time the test is run) so far I've created a Regex extractor which retrieves anything between the table now I need to create a beanshell post processor which retrieves the certain values from the variable retrieved by the Regex extractor and applies them to the HTTP request. I'm not to sure if this is the best way to do this so I am open to suggestions on doing this another way.
1 Answers
0
votes
- You need Beanshell PreProcessor applied to 2nd request, not PostProcessor applied to 1st request
- I don't think that using Regular Expressions is a very good idea to parse HTML, I would suggest going for CSS/JQuery Extractor or XPath Extractor instead
Once you have required values in form of
var_1=foo var_2=bar var_MatchNr=2
You will be able to add these values to the 2nd HTTP Request like:
import java.util.Iterator; import java.util.Map; Iterator iter = vars.getIterator(); int counter = 1; while (iter.hasNext()) { Map.Entry e = (Map.Entry)iter.next(); if (e.getValue() != null) { if (e.getKey().toString().startsWith("var_") && e.getValue().toString().length() >0) { sampler.addArgument("param" + counter, e.getValue().toString()); counter++; } } }