art_tykh
art_tykh

Reputation: 169

SOAPUI: Read http log with groovy script

is there any way to read http log for specific test step?

In my http log there are several response-requests messages for current test step.

The following code gives me only first request/last response, but I need to take value from second response.

log.info context.expand('${getHashValue#Request}')
log.info context.expand('${getHashValue#Response}')

Any ideas?

Thanks.

UPD: enter image description here

Upvotes: 1

Views: 1962

Answers (1)

Gaurav Khurana
Gaurav Khurana

Reputation: 3936

Below code can get any kind of soap ui logs

def logArea = com.eviware.soapui.SoapUI.logMonitor.getLogArea( "http log" )

//error log can be replaced with jetty log, script log, SoapUI log, error log,memory log, wsrm log

if( logArea !=null )
{
  def model = logArea.model
  if( model.size > 0 )            
     for( c in 0..(model.size-1) )         
      {
        def value= model.getElementAt(c).toString()
        if(value.contains("ETag")) // here you can mention if you want to extract anything particular from the logs
        {
        log.info  "value = " + value
        }
      }
}

this code can be even little modified to save soap ui logs in a file

credits :- https://webservice-testing.blogspot.in/2012/04/capture-soapui-logs-to-file.html

Upvotes: 0

Related Questions