Dear Dimitri. I didn't want to create more confusion, so I didn't use groovy. Apologies for that. I'll investigate. Thanks for taking the time to reply.
Lionel Blanco | *Tester QA Automation* El jue, 9 mar 2023 a las 15:34, Dmitri T (<glin...@live.com>) escribió: > Lionel Blanco wrote: > > Hello everyone. > > I did it in the following way: > > > > This is my BeanShell PreProcessor: > > > > 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; > > } > > imagen.png > > > > > > *This is my HTTP Request: * > > > > imagen.png > > > > *This is my WHILE: * > > imagen.png > > *This is my RESPONSE: * > > > > imagen.png > > What I can't achieve is that in each iteration, execute a new > > number.Example: > > Execution 1: 10001001 > > Execution 2: 10001002 > > Execution 3: 10001003 > > > > Someone give me 15 minutes of their valuable time and write me the > > code to do that? > > Thank you for your patience. > > > > Lionel > > > > El jue, 9 mar 2023 a las 9:30, Jun Zhuang > > (<thornbird...@yahoo.com.invalid>) escribió: > > > > Since you are using a preprocessor, I suppose you only need to > > deal with 1 value every iteration, so the array list may be > > unnecessary. A string variable should be enough. In this specific > > example, if you want to remove the brackets, you can use a java > > substring function. > > > > String sFinalValue = sCurrent.substring(1, sCurrent.length() - 1); > > > > BTW, Beanshell preprocessor is more expensive than JSSR223. > > On Wednesday, March 8, 2023 at 08:34:50 PM EST, Lionel Blanco > > <mlionelbla...@gmail.com <mailto:mlionelbla...@gmail.com>> wrote: > > > > > > > > Owen, After reading the link of the variables, I understood how it > > works. I managed to get it to work, but it gives me the number > > with "brackets". [30000007] . > > Do you know how to make them not happen? > > > > My code: > > > > importjava.util.ArrayList; > > Stringregion=vars.get("region"); > > Stringcanales=vars.getObject("canales"); > > ArrayListmyList=newArrayList(); > > > > switch(region){ > > case"GT": > > myList.add("30000007"); > > vars.putObject("canales",myList); > > break; > > } > > > > Response: > > > > imagen.png > > > > Lionel Blanco | *Tester QA Automation* > > > > El mié, 8 mar 2023 a las 21:42, Lionel Blanco > > (<mlionelbla...@gmail.com <mailto:mlionelbla...@gmail.com>>) > escribió: > > > > Thanks for your answer friend. I can't understand well. Would > > you help me here in the example? > > > > > > Stringregion=vars.get("region"); > > String[]myList=vars.get("canales"); > > > > switch(region){ > > case"GT": > > myList.add("30000007"); > > myList.add("70000007"); > > myList.add("90000007"); > > vars.put("canales",myList); > > break; > > } > > > > > > > > Lionel Blanco | *Tester QA Automation* > > > > > > > > El mié, 8 mar 2023 a las 20:24, Owen Pahl > > (<owen.p...@gmail.com <mailto:owen.p...@gmail.com>>) escribió: > > > > Hi Lionel, > > > > Jun Zhuang is correct. vars.put() and vars.get() work with > > strings. > > If you want to store/retrieve objects you need to use > > vars.getObject and vars.putObject. Don't forget you'll > > likely need to cast the return value of getObject. > > > > See the javadocs here > > > https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html > > > > > > Cheers, > > Owen > > > > > > On Thu, 9 Mar 2023 at 12:08, Jun Zhuang > > <thornbird...@yahoo.com.invalid> wrote: > > > > I think vars.get() always returns a string - don't > > think it can return an array. > > On Wednesday, March 8, 2023 at 05:52:49 PM EST, Lionel > > Blanco <mlionelbla...@gmail.com > > <mailto:mlionelbla...@gmail.com>> wrote: > > > > > > Hello to the whole community. I need help with this > > "Beanshell preprocessor". I want to make a list, and > > pass it in a while. Can someone tell me why it doesn't > > work? > > > > Stringregion=vars.get("region"); > > String[]myList=vars.get("canales"); > > > > switch(region){ > > case"GT": > > myList.add("30000007"); > > myList.add("70000007"); > > myList.add("90000007"); > > vars.put("canales",myList); > > break; > > } > > > > > > imagen.png > > > > Lionel Blanco | *Tester QA Automation* > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > > user-unsubscr...@jmeter.apache.org > > <mailto:user-unsubscr...@jmeter.apache.org> > > For additional commands, e-mail: > > user-h...@jmeter.apache.org > > <mailto:user-h...@jmeter.apache.org> > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscr...@jmeter.apache.org > > <mailto:user-unsubscr...@jmeter.apache.org> > > For additional commands, e-mail: user-h...@jmeter.apache.org > > <mailto:user-h...@jmeter.apache.org> > > > If you want to keep using your beautiful Beanshell code, although you > have been told to use Groovy 3 times already, which does nothing by the > way you can achieve "is that in each iteration, execute a new number" by > using the following __ Beanshell() function > <https://jmeter.apache.org/usermanual/functions.html#__BeanShell> (yes, > we remember, you love Beanshell) > > ${__BeanShell(vars.get("canales").split("\,")[Integer.parseInt(vars.get("__jm__While > > Provisioning Product FIja__idx"))].trim(),)} > > put it instead of ${canales} in your HTTP Request sampler. > > P.S. You can see what JMeter Variables are defined along with their > respective values using Debug Sampler and View Results Tree listener > combination <https://www.blazemeter.com/blog/debug-jmeter> > P.P.S. You might want to use ForEach Controller > < > https://jmeter.apache.org/usermanual/component_reference.html#ForEach_Controller> > > instead of the While Controller >