Search code examples
jmeterbeanshell

Using beanshell variable in subsequent While loop


I need to use variable from beanshell in my while loop, but I am not able to see the value of variable coming through.

output variable of my JDBC select count(*) query is "count_num"

using following code in beanshell:

int id = Integer.parseInt(vars.get("count_num_1").trim());

Following is the structure of my test plan:

-JDBC request (o/p variable is count_num)
-beanshell sampler (parse string count_num to integer)
-While Controller: vars.get(${i})>0)   
  -http request1
  -http request2
  - (beanshell code to decrease "i" by 5 - not sure how??)

What am i doing wrong in usage of "i" and also how to decrease count of "i" by 5 towards the end of while loop.


Solution

  • Put variable string value after adding 5

     vars.put("count_num_1", String.valueOf(id +5));