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:

  1. add beanshell assertion child of http request need test.
  2. 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"; } 

    jmeter beanshell assertion css js

  3. if of specified thresholds met, sampler failed relevant message:

    assertion failure message

more information on conditionally failing jmeter tests: how use jmeter assertions in 3 easy steps


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -