While recording a test, when I select a checkbox then it returns 'On' as value. I have made my test plan in JMeter and now I need to randomly set value to this field as On or OFF on every request.
Can I achieve it using Beanshell scripting + Split or Random function?
You can use __RandomFromMultipleVars function to random between values
The RandomFromMultipleVars function returns a random value based on the variable values provided by Source Variables
If you put ON and OFF inside variables, e.g. inside on
and off
JMeter variables, then you can use:
${__RandomFromMultipleVars(on|off, rnd)}
It will save the random value inside rnd
variable (second parameter) that can be used later as ${rnd}
Another option to get same result is to add the following JMeter variables:
a_matchNr = 2
a_1 = on
a_2 = off
Then use function with JMeter variable prefix a
:
${__RandomFromMultipleVars(a, rnd)}