从数组中获取随机值
问题描述:
我定义了一个新变量
Name Value Description
categories (1, 2, 3, 4, 5) my categories ids
在我的路径中,我想从以下类别中获取随机值:category_id=my_random_value
.
and in my path i want to get a random value from categories: category_id=my_random_value
.
我什至尝试过
category_id=${__StringFromArrayAtRandomindex('1', '2', '3', '4', '5'}
但它不起作用.
答
__ StringFromArrayAtRandomindex既不是JMeter核心的一部分,也不是JMeter插件的一部分.
__StringFromArrayAtRandomindex is not part of JMeter core nor part of JMeter plugins.
这是自定义函数吗?
此外,您遇到语法错误(结尾缺少 ) :
Furthermore, you have a syntax error (there is a missing ) at end:
${__StringFromArrayAtRandomindex('1', '2', '3', '4', '5')}
要执行相同的操作,请使用包含以下内容的CSV数据集:
To do the same thing, use a CSV Data Set which will contain:
1
2
3
4
5
设置:
Variable Names=categoryId
然后您可以像这样使用它:
You can then use it like this:
${categoryId}