Want to capture the response from the first validated sampler within a Random Order Controller

26 views Asked by At

Trying to validate scenario like Have 10 samplers(each sampler having unique session ID) in Random Order Controller, Want to capture the response from first validated sampler from the Random Order Controller.

can any one help on this scenario.

1

There are 1 answers

0
Ivan G On

I can think of the following approach:

  1. Before the Random Order Controller add a JSR223 Sampler and put the following code there:

    new File('response.txt').delete()
    
  2. Add a JSR223 PostProcessor to the Random Order Controller and use the following code there:

    def response = new File('response.txt')
    
    if (!response.exists()) {
        response.bytes = prev.getResponseData()
    }
    

    enter image description here

This way you will get the response of the first Sampler executed by the Random Order Controller in response.txt file, if you need the response later on you can get it using i.e. __FileToString() function

More information on Groovy scripting in JMeter: The Groovy Templates Cheat Sheet for JMeter