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?

Narendra Chandratre
2,8347 gold badges31 silver badges60 bronze badges
asked Oct 27, 2016 at 9:11

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:

answered Oct 28, 2016 at 5:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.