0
votes

Am new to JMeter. I have extracted my required values from response data using regular expression extractor. Now I need to use these etracted values to select a particular data from the list.

I have few data listed. In these data, few have edit enabled and few data's edit are disabled. I have to instruct JMeter to select data that have edit enabled. there are 3 conditions to have edit enabled which is:

is_final = 1 
is_locked = 0 
status_id = 1

I have extracted these values from response data. But I donot know how to use BeanShell to instruct JMeter to select data that have edit enabled. Please help me on this.

2
where is the list? what kind of list? what kind of data do you want jmeter to select? - CharlieS

2 Answers

1
votes

the syntax of the Beanshell script is quite similar to Java. Say, you have a list of elements: ArrayList<element> list and each element has fields:is_final,is_locked,status_id, so you can write a loop to go through all the elemnts in the list like

 for(int i = 0; i < list.size(); i++){
        if(list.get(i).is_final == 1 && list.get(i).is_locked == 0 && list.get(i).status_id == 1){
           return list.get(i);
        }

hope this is helpful to you! about jmeter's introduction on beanshell and beanshell's offifical wiki

0
votes

If you want to use the single values out of Extracted array. First you need to understand these variables are stored as for eg:MYREF_g0,MYREF_g1,MYREF_g2

So if you wanted to extract say status_id in your case which is stored at 3rd array position in ReferenceName say Abc. then refrence variable name should be${Abc_g2}.

Same applies for other values like ${Abc_g0},${Abc_g1}.

Hope this helps.!