我有第一個線程組獲取一些id並將其寫入變量。 這個var有這樣的視圖「654564546,564564,56454,56456454,21231321,8972341,65423187」。 我需要隨機選取其中一個id並將其放到另一個變量中。 在JMeter的2.07我用這個代碼:JMeter 2.10從字符串獲取數據的隨機變量
import java.util.Random;
String[] erroridcox = (vars.get("erroridcox")).split(",");
int id1 = new Random().nextInt(erroridcox.length);
String randerror = (erroridcox[id1]);
vars.put("rnd_erroridcox", randerror);
但在2.10的JMeter這個代碼不起作用。 的JMeter日誌說:
jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import java.util.Random; String[] erroridcox = (vars.get("erroridcox")).split(. . . '' : Typed variable declaration
發現問題。問題是由於我的erroridcox字符串具有這樣的視圖:'code'[「45654」,「564564」,「908098」]'code'。你能否讓我跳過符號[]「 –
我已經閱讀過有關trim函數,但我不知道如何在BeanShell預處理器中使用它。 –