Forum Discussion

roja1's avatar
roja1
Contributor
6 years ago

trying to get response using instanceof RestTestRequestStep

import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep
import com.eviware.soapui.support.XmlHolder
import jxl.*
import jxl.write.*
def count=0,i=1
Workbook existingWB=Workbook.getWorkbook(new File("C://eprimo/TestData/input.xls"))
WritableWorkbook workbookcpy=Workbook.createWorkbook(new File("C://eprimo/TestData/Output2.xls"),existingWB)
workbookcpy.createSheet("Output2",2)

WritableSheet aCopySheet = workbookcpy.getSheet("Output2")
jxl.write.Label anotherWritableCell1 = new jxl.write.Label(0,0 ,"Test Step")
jxl.write.Label anotherWritableCell2 = new jxl.write.Label(1,0 ,"Request URL")
jxl.write.Label anotherWritableCell3 = new jxl.write.Label(2,0 ,"Request Payload")
jxl.write.Label anotherWritableCell4 = new jxl.write.Label(3,0 ,"Response")
aCopySheet.addCell(anotherWritableCell1)
aCopySheet.addCell(anotherWritableCell2)
aCopySheet.addCell(anotherWritableCell3)
aCopySheet.addCell(anotherWritableCell4)
(0..context.testCase.testStepCount-1).each{
def step = context.testCase.testStepList[it]
if ( step instanceof RestTestRequestStep) {
jxl.write.Label anotherWritableCell5 = new jxl.write.Label(0,i ,step.name)//to save test step name i
aCopySheet.addCell(anotherWritableCell5)
jxl.write.Label anotherWritableCell6 = new jxl.write.Label(1,i ,step.service+step.resource)//to save request
aCopySheet.addCell(anotherWritableCell6)
def response = context.expand('${step.name#Response}')
jxl.write.Label anotherWritableCell7 = new jxl.write.Label(3,i ,response)
aCopySheet.addCell(anotherWritableCell7)
count=count+1
i=i+1
}
}
workbookcpy.write()
workbookcpy.close()
existingWB.close()

 

i'm trying to get a copy of input data in 1st sheet and get output on the second sheet.

I'm iterating through only the request which are rest and trying to save test step name, request and response in to the excel.In this step def response = context.expand('${step.name#Response}') ,intead of hardcoding my test step name I tried to get it from step.name,This is not returining me any error and also not writing response . 

Please help me with this. I'm iterati

No RepliesBe the first to reply