Wednesday, April 8, 2020

JMeter : Debug Sampler , JSR223 Sampler , Reading a text file content

Create a text file and save in JMeter/bin folder


Select Groovy in drop down, we have other scripting languages support also

import org.apache.jmeter.util.JMeterUtils;
String fileContents = new File('./nameOfFileToRead.txt').getText('UTF-8');
vars.put("your_fileContentsVariableName",fileContents);
log.info("Message:" + vars.get("your_fileContentsVariableName"));


Add a Debug Sampler, to get all the JMeter variables used in the test plan. Set all dropdowns as true.

 In the Debug Sanpler, Response Data , we can see the text file content.


Also open the JMeter console. The same is displayed here also. Because we have used the following line.

log.info("Message:" + vars.get("your_fileContentsVariableName"));


No comments:

Post a Comment

JMeter Simple Controller

  Simple Controller is just a  container  for user request.