Generate random values in JSR223 sampler in JMeter

venkat sai

def index = [];
def randoms = [];
def size = new File("C:/Users/320027671/Desktop/JmeterPerformanceSuit/CompleteSuit/STU3/Post/index.csv").readLines().size();
File file = new File("C:/Users/320027671/Desktop/JmeterPerformanceSuit/CompleteSuit/STU3/Post/index.csv");
file.each { line ->
	index << line
	randoms << __Random(0,size,)
}

The script is giving error

the method does not exists

the scirpt is working uptil index << line, the problem is with random function

user7294900

I assume you use groovy as language (otherwise it won't work)

You can't use JMeter functions inside JSR223

You can randomize every line using for example RandomUtils:

org.apache.commons.lang3.RandomUtils.nextInt(0, size-1); 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

JMeter - groovy MultipleCompilationErrorsException in JSR223 Sampler

Jmeter - declare array variable in one JSR223 Sampler in order to access it in another JSR223 Sampler

JMeter Javascript language not available for JSR223 Sampler and WebDriver Sampler

Problem in JSR223 script JSR223 Sampler, while connecting to Azure Cosmos DB from Jmeter

JMeter - Exception when using Beanshell as JSR223 Sampler with file

JMeter - JSR223 Sampler missing character encoding

Jmeter JSR223 Sampler - Unable to Write Data To CSV File

JMeter - Access JSR223 variable in HTTP sampler

Create JMeter Test Plan using JSR223 Sampler

Read json file in jsr223 sampler in jmeter and extract data

Code in JMeter JSR223 Sampler comments is executed

How to update User Defined Variable in JMeter in JSR223 Sampler?

"Precondition Failed" for post request in JSR223 Sampler in JMeter

upload a file using jsr223 sampler getting failure on JMeter

Jmeter: Access all results from all threadGroups from JSR223 Sampler or BeanShell Sampler in TeardownThread

JMeter Load Tesing::Moving from WebDriver sampler To JSR223 sampler with groovy

Comparing two values in JMeter with JSR223 Assertion

JMeter saving document to MongoDb with Java BeanShell: Problem in JSR223 script Sampler

JMeter - Error when using Jython/Python Engine in JSR223 Sampler "Cannot find Engine"

Get all previous sampler results (redirects) in JMeter's JSR223 Assertion

Trouble accessing properties set by JSR223 Sampler in JMeter non-GUI mode

Error when trying to execute existing Jmeter script in Maven project that is written in Jsr223 sampler in groovy

File declaration throwing error in JMeter, JSR223 sampler with groovy script

Difference between a JSR223 Sampler and JSR223 PreProcessor

Extract value from jsr223 sampler

How can I get the current parent sample "Sampler results" properties values in a child JSR223 Postprocessor test element?

JMeter JSR223 PostProcessor GET COOKIE

unexpected token while reading xml to string in JSR223 sampler

In what ways can I access a variable defined in a JSR223 Sampler from inside a child JSR223 PostProcessor?

TOP Ranking

HotTag

Archive