PradeepKumar February 2016

How to use Regular Expression extractor for output data of- 6002:6005:93974309c3f042a69b20c9f9c38a13e3

In my service response output is just like as below :

6002:6005:93974309c3f042a69b20c9f9c38a13e3

there is no other things come in output ,it returns above value ,I want write this values into one local file for all requests.

Answers


Dmitri T February 2016

Option 1: add the value to .jtl results file:

  1. Add Regular Expression Extractor as a child of the request which returns this value and use the following Regular Expression Extractor configuration:

    • Reference Name: anything meaningful, i.e. serviceResponse
    • Regular Expression: (.*)
    • Template: $1$
  2. In user.properties file add the next line:

    sample_variables=serviceResponse
    

    Upon next execution you will see an extra column in your results .jtl file containing values extracted from the response. See Sample Variables chapter of JMeter's User Manual for more information.


Option 2: writing variables into a separate file

  1. Instead of the Regular Expression Extractor add Beanshell PostProcessor as a child of the request which returns that value.
  2. Put the following code into the PostProcessor's "Script" area:

    import org.apache.commons.io.FileUtils;
    
    FileUtils.writeStringToFile(new File("/path/to/your/file.txt"),new String(data) + System.getProperty("line.separator"), true);
    

    The above code uses FileUtils.writeStringToFile() method to store the whole response into an arbitrary file. See How to Use BeanShell: JMeter's Favorite Built-in Component article for more information on using Java and JMeter API from Beanshell test elements in your JMeter test.

N.B. if you plan to produce high load go for option 1.

Post Status

Asked in February 2016
Viewed 3,406 times
Voted 14
Answered 1 times

Search




Leave an answer