Jmeter - How to check if less than 10 stylesheets are loading when I open a web page -
i have requirement need verify when open web page, there should less 10 stylesheets , less 20 .js loading. there way in jmeter?
it is, need scripting. example solution:
- add beanshell assertion child of http request need test.
put following code beanshell assertion "script" area:
import org.apache.jmeter.samplers.sampleresult; int js, css; js = css = 0; (sampleresult subresult : sampleresult.getsubresults()) { if (subresult.geturlasstring().endswith(".css")) { css++; } else if (subresult.geturlasstring().endswith(".js")) { js++; } } log.info("js files: " + js); // can comment or remove these lines log.info("css files: " + css); // nothing print numbers jmeter.log if (css > 10 || js > 20) { failure = true; failuremessage = "exceeded maximum scripts/styles"; }
if of specified thresholds met, sampler failed relevant message:
more information on conditionally failing jmeter tests: how use jmeter assertions in 3 easy steps
Comments
Post a Comment