Retrieving certain values from a variable jMeter beanshell script -
currently developing script in jmeter, need retrieve x amount of values response push values http request, here tricky part response table changes (e.g. rows increase or decrease each time test run) far i've created regex extractor retrieves between table need create beanshell post processor retrieves values variable retrieved regex extractor , applies them http request. i'm not sure if best way open suggestions on doing way.
- you need beanshell preprocessor applied 2nd request, not postprocessor applied 1st request
- i don't think using regular expressions idea parse html, suggest going css/jquery extractor or xpath extractor instead
once have required values in form of
var_1=foo var_2=bar var_matchnr=2
you able add these values 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++; } } }
Comments
Post a Comment