0

Having the following request:

enter image description here

From this I extract using the Regular Expression Extractor the following string:

%5B1172%2C63%2C61%2C66%2C69%2C68%5D

I decode this using the urldecode function: ${__urldecode(${Groups_g2})}

Decoded: [1172,63,61,66,69,68]

On the following request I want to extract the values using the BeanShell PreProcessor to obtain a list of parameters like this one:

enter image description here

I know that I have to use sampler.addArgument but i can't figure how to extract data from the list and add the values as parameters.

1 Answer 1

3

Try the following:

  1. Put ${__urldecode(${Groups_g2})} into Beanshell PreProcessor's Parameters input field
  2. Enter the following code into Script area

    String params = Parameters.substring(1, Parameters.length() - 1); // remove square brackets
    int counter = 1;
    for (String param : params.split(",")) { 
      sampler.addArgument("parameter" + counter, param);
      counter++;
    }
    

I have no idea what parameter names need to look like, hopefully above information will be helpful.

HTTP Request with no parameters:

Empty HTTP Request

Beanshell PreProcessor

Beanshell PreProcessor

Parameters in View Results Tree Listener

Parameters in View Results Tree Listener

For more information on Beanshell scripting in Apache JMeter check out How to use BeanShell: JMeter's favorite built-in component guide.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.