I\'m sure I\'ve already done this in the past but somehow I cannot figure out how ;-) So, here\'s my problem:
I\'m trying to create a JUnit test plan in which a HTTP re
Concerning implementing ${__StringFromArrayAtRandomIndex('3', '2', '54', '42')}
.
Suppose you can easily implement your scenario using e.g. BeanShell Sampler / BeanShell PostProcessor with a bit of code.
E.g.:
Set your source variable (via e.g. User Defined Variables):
Name Value categories 3,2,54,42,37
(i.e. use comma as delimiter, no spaces before and after comma).
Use add BeanShell Sampler/PostProcessor with the following code:
import java.util.Random; String[] categories = (vars.get("categories")).split(","); int idx = new Random().nextInt(categories.length); String category = (categories[idx]); vars.put("categoryId", category);
${categoryId}
.