Forum Discussion

ripplegupta's avatar
ripplegupta
Contributor
8 years ago

How to get rawrequest and response test step using context or projectrunner variable?

I am iterating through test steps in project event handler and trying to get the raw request for each test step (rest request and jdbc only) with something like below,

 

projectRunner.getResults().each(){
	it.getResults().each() {
	 	it.getResults().each() {
                    it.getTestStep().testRequest.RawRequestData
                }
        }
}

But it is giving me only json body that too with parameterized properties not actual data, after submitting request. I want data that comes up in raw tab . Can somebody suggest what could be the right way?

6 Replies

    • Radford's avatar
      Radford
      Super Contributor

       

      The RawRequest is a test step property, thus accessed via getProperty method. Try something like this:

       

      projectRunner.getResults().each(){ testSuiteRunner -> 
      
      	testSuiteRunner.getResults().each() { testCaseRunner ->
      		
      	 	testCaseRunner.getResults().each() { testStepResult ->
      	 	
      	 			// Make sure that the test step has properties (not sure if there are any that don't but just being safe).
      				if(testStepResult.getTestStep() in com.eviware.soapui.model.TestPropertyHolder){
      					log.info('Test step "' + testStepResult.getTestStep().getName() + '" has properties.') 
      
      					// Make sure the test step has a RawRequest property before trying to read it.
      					if(testStepResult.getTestStep().hasProperty('RawRequest')){
      						log.info('Test step "' + testStepResult.getTestStep().getName() + '" has a RawRequest property.') 
      						log.info(testStepResult.getTestStep().getPropertyValue('RawRequest'))
      				}
      			}
      		}
      	}
      }

       

      Regarding the query about parametrised values, the documentation for the rest request test step states:

       

      • RawRequest - Binary request data. The same content you can see in the Raw view of the request editor without headers. Property expansions are converted to expected values.
      • Request - Request data with unconverted property expansions.

       

      If you find your experience is different to this I would log a support call with SmartBear

      • ripplegupta's avatar
        ripplegupta
        Contributor

        Thanks Radford, 

         

        I will check and get back here with confirmation , thanks for your information.