I am trying to automate Webservice execution using soapui (groovy scripting).
I have the following TestSteps:
- Data Source (Reads rows from and excel datasource)
- Properties
- SOAP Step
- Capture SOAP REQ-RES as xml files
- Generate Excel Report with xml
tag value parsed from response - Looper (Iterate the Test Case for
Total Rows in datasource excel file)
I have been successful in creating the framework but stuck in 5th step.
Step 5 executes successfully but creates report excel file having response data of only the last test iteration. A new workbook is created with each iteration which is overwritten by next iteration.
Please suggest changes so as to implement the feature which apppends response data for every iteration in excel sheet
I am using jxl api for writing parsed xml data using below code:
import jxl.*;
import com.eviware.soapui.support.XmlHolder
import jxl.write.*;
// create an excel workbook
WritableWorkbook workbook1=Workbook.createWorkbook(newFile("/Users/anant/Downloads/GroovyTest/report.xls"));
// create a sheet in the workbook
WritableSheet sheet1 = workbook1.createSheet("Report Worksheet", 0);
// Get the data to be added to the report
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder("divide#response")
def fieldFromResponse = holder.getNodeValue("//n:divideResponse/n:Result")
// create a label
Label label = new Label(0, 0, fieldFromResponse);
log.info fieldFromResponse
// Add the label into the sheet
sheet1.addCell(label);
workbook1.write();
workbook1.close();
Best Answer
Try this one using apache poi.. Don't know much about jxl. Pls ignore the extra imports.. Modified the a code to suit your requirement :) - Here no creation of file, sheet etc. everytime, coz that was the problem in your code. And also there wasn't any row incrementer also.