0
votes

I have a Http request with Body Data which can create individual user any time when it runs for example:

{"username":"fakeuser${__RandomString(5,abcdefghijklmnofqrst1234567,userno)}","email":"fakeuser${userno}@fakedomain.com","password":"blblabla123!","passwordRepeated":"blablabla123!"}

POST Data:
{"username":"fakeuser4mf7s","email":"[email protected]","password":"blablabla123!","passwordRepeated":"blablabla123!"}

Is there any way to grab email and password value from the Post Data and save it to the same csv file any time when specific http request sample runs.

1

1 Answers

0
votes
  1. Add JSR223 PostProcessor as a chid of the HTTP Request sampler
  2. Put the following code into "Script" area:

    import groovy.json.JsonSlurper
    
    def request = new JsonSlurper().parseText(sampler.getArguments().getArgument(0).getValue())
    def email = request.email
    def password = request.password
    
    new File('test.csv') << email + ',' + password + System.getProperty('line.separator')
    

Once you execute your test the JSR223 PostProcessor will add the values of email and password objects into test.csv file (normally it should reside in "bin" folder of your JMeter installation)

References: