本文介绍了从数组中获取随机值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我定义了一个新变量
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}
这篇关于从数组中获取随机值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!