0

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.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
PradeepKumar
  • 203
  • 2
  • 7

1 Answers1

0

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.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • I followed Option 1 but I could not able to capture response.I add the Reg Ext and the variable in user.properties but not seeing the results contains extra column which you mentioned - Upon next execution you will see an extra column in your results .jtl file containing values extracted from the response. what do u mean by this ? Can you please let me know the steps for this ? – PradeepKumar Feb 08 '16 at 19:34
  • Sorry now it's working fine .Thanks a lot for quick solution – PradeepKumar Feb 08 '16 at 20:14
  • You need to restart JMeter to pick the property change up. See [Apache JMeter Properties Customization Guide](https://blazemeter.com/blog/apache-jmeter-properties-customization) article for comprehensive information – Dmitri T Feb 09 '16 at 16:02