cancel
Showing results for 
Search instead for 
Did you mean: 

Inserting data to excel with Groovy script

New Contributor

Re: Inserting data to excel with Groovy script

will u please explain the above code.i am beginner in  soap ui pro

 

 


CL = 0;
rows = sheet1.getRows();
for( tc_row in 1..rows-1){
WritableCell tmpA = sheet1.getCell(CL,tc_row);
String s1 = tmpA.getContents();
log.info("$s1")
Label label = new Label(CL,tc_row,s1);
sheet2.addCell(label); 

Frequent Visitor

How to save each request and response in file using Groovy .

Hi,

 

 

Using SoapUI Open Source.

How to save each request and response in file , when input the data from Excel.

 

I tried but I can only save first input from excel (Request and response).can anyone help on this please.

 

This my code:

def res=context.expand('${GetProduct#Request}')
new File("C:/Users/Psandhu/Req/REQUESTDATA.xml").write(res)

def myOutFile = "C:/Users/Psandhu/RES/RESPONSEDATA.xml"
def response = context.expand( '${GetProduct#Response}' )
def f = new File(myOutFile)
f.write(response, "UTF-8")

 

 

Second Code I tried this, but give me error for :

Groovy.Lang>missingPropertyException: No such Property:tetsStepresult for class

 

def pName = context.currentStep.testCase.testSuite.project.name //get project name
def pDate = new Date().format( 'yyyyMMdd' )//get current date
def sDate = pDate.toString()//convert date to string
def pTestSuite = context.currentStep.testCase.testSuite.name//get TestSuite name
def pTestCase = context.currentStep.testCase.name//get TestCase name
def filePath = 'C:/Users/Psandhu/'+pName+'_'+sDate+'/'+pTestSuite+'/'+pTestCase+'/'//compose the folder path
//
File file2 = new File(filePath)
if (!file2.exists()) file2.mkdirs()//create the destination folder
//

//
fos = new FileOutputStream(filePath+ testStepResult.testStep.label + '.txt', true)
pw = new PrintWriter( fos )
testStepResult.writeTo( pw )
pw.close()
fos.close()

New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors