Reputation: 97
I am using one Javascript function to generate a random Number.
Used a User Parameter(Preprocessor) under the request
Added a Variable: farmeid
Function: ${__javaScript('bam-'+parseInt((Math.random()*1000000),10))}
When I am using the varialble ${frameid}
, it is returning no Value.
Upvotes: 1
Views: 932
Reputation: 168197
The problem is that there is a comma in your expression here: ),10
which acts as a delimiter for function parameters. If you can remove this ,10
bit so your expression could look like:
${__javaScript('bam-'+parseInt(Math.random()*1000000),)}
This would be successfully evaluated by __javaScript function.
If this 10
bit is a must you can use BSF PreProcessor with the following code:
vars.put("frameid",'bam-'+parseInt((Math.random()*1000000),10));
And the easiest way is using __Random function like
bam-${__Random(111111,999999,)}
directly where it's required.
Hope this helps.
Upvotes: 3
Reputation: 748
It's better to use Jmeter's Random Variable generator. http://jmeter.apache.org/usermanual/component_reference.html#Random_Variable
Cheers,
Upvotes: 1