2

I need to verify a response message of Jmeter request with value stored in CSV file, for particular response message I need to read from nth cell(for ex 10ht row) 5th column data and need to verify with actual response message. How can I do this?

1 Answer 1

1

As far as I'm aware JMeter doesn't provide such functionality out of the box so you will need to do some scripting.

For example add Beanshell PostProcessor as a child of the sampler where you need to do this verification and put the following code into "Script" area

import org.apache.commons.io.FileUtils;    //necessary import

List lines = FileUtils.readLines(new File("/path/to/your/file.csv")); // read CSV file into the array of lines in memory
String row10 = lines.get(9);    // get row 10, in Beanshell counting starts from zero
String[] cells = line2.split(",");    //split row 10 into cells using comma as delimiter
String cell5 = cells[4];    // get value of 4th column, counting is zero-based

log.info("Cell5 value = " + cell5);    // print the value into jmeter.log file
vars.put("cell5value", cell5);    // store the value as ${cell5value} JMeter Variable

The above code will read the content of 10th row, 5th column cell and store the value into a JMeter Variable. You will be able to access it as ${cell5value} where required.

Demo:

Beanshell CSV Demo

References:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.