0

I'm trying to parameterize content of the file uploaded through CSV Data Set Config But file not picking the variables values ( can see the data of csv file in request but the uploaded file not updated with the number) Showing the request like this

**
POST data:
--3TJ-KduX0_gdJ3BvxwP97-p3PBN0Jki-2P7Iyvd
Content-Disposition: form-data; name="SO"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit

403331689
--3TJ-KduX0_gdJ3BvxwP97-p3PBN0Jki-2P7Iyvd
Content-Disposition: form-data; name="sourceFile"; filename="SO_perf_test_porfornmance.xml"
Content-Type: text/xml
Content-Transfer-Encoding: binary

**
Tomas By
  • 1,396
  • 1
  • 11
  • 23

1 Answers1

0

If you're sending the file via "Files Upload" tab of the HTTP Request sampler like this:

enter image description here

JMeter doesn't evaluate any Functions or Variables which are inside the file, it sends the file "as it is".

One of the solutions would be using a temporary file like SO_perf_test_porfornmance_modified.xml in the HTTP Request sampler and the content of this file can be modified "on-the-fly" using JSR223 PreProcessor like:

  1. Add JSR223 PreProcessor as a child of the HTTP Request sampler which uploads tile
  2. Put the following expression into "Parameters" section:

    ${__eval(${__FileToString(SO_perf_test_porfornmance.xml,,)})}
    

    where:

  3. Put the following code into "Script" area:

    new File('SO_perf_test_porfornmance_modified.xml').text = Parameters  
    
  4. Configure your HTTP Request sampler to send SO_perf_test_porfornmance_modified.xml file instead of the SO_perf_test_porfornmance.xml

    enter image description here

  5. That's it, JMeter will now be sending the new file which contains all the nested functions and/or variables resolved to their respective values

Dmitri T
  • 159,985
  • 5
  • 83
  • 133