Just thought I'd pass this on.
I've been trying to simulate an online test where users have to write a one
word answer to each question.
I wanted the response to be a random selection from several possibilities, I
thought this would be a fairly simple thing but all the posted solutions
seemed quite complex.
In the end I came up with a simple solution using a single variable and
regexp.
I set the options in a variable with a common separator (= in the following
example)
weekday : Monday=Tuesday=Wednesday=Thursday=Friday=
Then to select a random answer I used the following regexp:
${__regexFunction(([^=]*)=,$1$,RAND,,Anyday,,weekday)}
The two '=' in the expression must match the separator used in the variable.
'Anyday' is the response if no matches exist in the specified variable (i.e.
something has gone wrong)
weekday is the name of the variable containing the options
If you wanted a lot of choices, you could read the 'value choices' in from a
CSV file (different choices on each line). This wouldn't give a totally
random selection but would be more random than reading values from a CSV
file that are in a pre-defined order.
CSV example file (select one type of animal):
Dog=Fish=Whale=,
Cat=Monkey=Elephant=Mouse=,
Frog=Lion=,
Another use for this might be to make the variable part of a URL to go to
one of several predefined locations.
e.g. /home.html=/help.html=/products.pdf=
Hope people find this useful
--
View this message in context:
http://jmeter.512774.n5.nabble.com/Simple-Random-Text-Value-selection-tp5714201.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]