问题描述
我的应用程序包括选择标题"下拉列表,其中包含的值包括Mr,Miss,Dr&太太
My application consist the Select Title drop down list contains values as Mr, Miss, Dr & Mrs.
我想为不同的线程捕获不同的标题(随机但从4以上).请提出可能.
I want to capture the different title (Random but from above 4) for different thread. please suggest how it is possible.
这是我的脚本,我已将title参数传递为$ {randomTitle}
This is my script i have pass the title parameter as ${randomTitle}
将值传递给数据库,
Value pass to database as,
将请求发布为
推荐答案
出于兴趣,在此使用枚举是否至关重要?
Out of interest, is it vital to use enum there?
尝试如下修改您的代码:
Try amending your code as follows:
import java.util.Random;
String[] frm_titles = {"Mr", "Miss", "Dr", "Mrs"};
Random randGenerator = new Random();
int randInt = randGenerator.nextInt(frm_titles.length);
vars.put("randomTitle",frm_titles[randInt]);
它应该以这种方式工作.如果需要使用枚举结构,则Enum一定不能在Beanshell解释器中本地化-将其编译为.jar并将其放置到JMeter类路径中.
It should work this way. Enum must not be local to Beanshell interpreter, if you need to use enum structure - compile it as .jar and place it to JMeter classpath.
请参见如何使用BeanShell:JMeter最喜欢的内置组件指南,以获取有关Apache JMeter中Beanshell脚本的更多详细信息.
See How to use BeanShell: JMeter's favorite built-in component guide for more details on Beanshell scripting in Apache JMeter.
这篇关于如何在jmeter中捕获特定于线程的不同数据表单下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!