jmeter - How can I use If controller with Beanshell postprocessor -


here map looking :

  1. if user login retailer follow specific requests
  2. if user login reseller follow specific requests

what have done retailer :

  1. i have added 1 http post request login retailer
  2. also added beanshell postprocessor url of previous request return above login post request.
  3. i have added following code beanshell postprocessor make sure if returned url contains word "retailer" or not.

code :

string url = prev.geturl().tostring(); vars.put("url", url);  if (vars.get("url").contains("retailer")) {     log.info("pass"); } else {     log.info("fail"); } 

above code works well.

  1. next have added if controller , added retailer related http requests under if controller. not sure should write if controller tell if previous url contains word "retailer" follow http requests under if controller.

i tried following if controller seems not working :

"${url}".contains("retailer") 

i feel jmeter ignoring if controller not getting error.

goal execute specific requests based on user role retailer/reseller.

you don't have contains() function in javascript, need use indexof() function instead if controller condition should like:

"${url}".indexof("retailer") != -1 

remember jmeter.log file when test doesn't work expected, in 99.9% of cases can figure out reason it.


Comments