0

I have created a script in JMeter to download a file and now I have to get the name of the downloaded file [filename] from sampler response to store it in a csv file, I have tried to configure the sampler response but it didn't help me out. please see the following

Response headers:
HTTP/1.1 200 OK
Cache-Control: private
Pragma: no-cache
Content-Length: 1235270
Content-Type: application/octet-stream
Expires: Mon, 20 Apr 2015 12:10:35 GMT
Server: Microsoft-IIS/6.0
content-disposition: attachment; **filename="10098_testcase_package.pct**"
RaGe
  • 22,696
  • 11
  • 72
  • 104
Prateek Bhati
  • 25
  • 1
  • 8

1 Answers1

2

If you need to get "filename" bit from response header you can use Regular Expression Extractor post processor for it

  1. Add Regular Expression Extractor as a child of the request which returns the header
  2. Configure it as follows:

    • Field to check: Response Headers. It matters as by default the Extractor looks up in the response body and you need the header.
    • Reference Name: any variable name, i.e filename
    • Regular Expression: filename="(.+?)"
    • Template: $1$

    Other fileds may be left blank

Regular Expression Extractor

You can refer extracted value as ${filename} where required.

For more information on correlation in JMeter check out Using RegEx (Regular Expression Extractor) with JMeter guide.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • It works, thanks. But i have a query, how to provide the reference name in a csv – Prateek Bhati Apr 20 '15 at 13:22
  • @PrateekBhati To write values to files, you can use a beanshell postprocessor. See [here](http://stackoverflow.com/questions/8352281/write-extracted-data-to-a-file-using-jmeter) – RaGe Apr 20 '15 at 15:47