Lionel Blanco 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*
*vars* stands for JMeterVariables
<https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html>
class instance, if you take a look at documentation on vars.put()
<https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html#put(java.lang.String,java.lang.String)>
function you will see that both arguments are Strings
<https://docs.oracle.com/javase/7/docs/api/java/lang/String.html>
If you want to store anything else - you will need to use
vars.putObject()
<https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html#putObject(java.lang.String,java.lang.Object)>
for storing theĀ value and vars.getObject()
<https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html#getObject(java.lang.String)>
for reading the value
In general since JMeter 3.1 it's recommended to use 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>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@jmeter.apache.org
For additional commands, e-mail: user-h...@jmeter.apache.org