Dmitri, Dimitri thank you very much, I was able to solve it. Very kind.

El jue, 15 jun 2023 a las 6:52, Dmitri T (<glin...@live.com>) escribió:

> Lionel Blanco wrote:
> > Hello everyone.
> >
> > I need help with forEach Controller.
> >
> > I made this arraylist code in the Beanshell Preprocessor and I need to
> > iterate through it in a post request.
> >
> > imagen.png
> > imagen.png
> >
> > imagen.png
> >
> > I understand that this is done with the forEach Controller but I can't
> > figure out how to use it.
> >
> > imagen.png
> >
> > If my beanshell code is this, how do I use it in the
> > forEachController?  Thank you
> >
> > importjava.util.ArrayList;
> >
> > Stringregion=vars.get("region");
> > Stringcanales=vars.getObject("canales");
> >
> > ArrayListmyList=newArrayList();
> >
> > switch(region){
> > case"GT":
> > myList.add("10001001");
> > myList.add("10001002");
> > myList.add("10001003");
> > StringlistString=String.join(", ",myList);
> > vars.putObject("canales",listString);
> > break;
> > }
> >
> >
> >
> >
> In order to be able to run your request 3 times with different
> typeServiceID you need to amend your code to look like:
>
> String region =vars.get("region");
>
> switch (region){
>      case "GT":
>          vars.put("canales1","10001001");
>          vars.put("canales2","10001002");
>          vars.put("canales3","10001003");
>          break;
> }
>
>
>
> and in the ForEach Controller
> <
> https://jmeter.apache.org/usermanual/component_reference.html#ForEach_Controller>
>
> use *canales* as the "Input variable prefix" and "Output variable name"
>
> Also be aware that starting from JMeter 3.1 you should be using JSR223
> Test Elements and Groovy language for scripting
> <https://jmeter.apache.org/usermanual/best-practices.html#bsh_scripting>
> so consider migrating. More information:Apache Groovy: What Is Groovy
> Used For? <https://www.blazemeter.com/blog/apache-groovy>
>
>

Reply via email to