ContributionsMost RecentMost LikesSolutionsError while writing Xpath expression for a json response in soapUI Hi, I have been trying to extract value from the json repsonse using Xpath in the property transfer step. I could do it using json path match but not Xpath. For some reasons I need to extract it using Xpath only. PFA for the json path match which is giving response. I have already tried this "/response/data[0]/number[0]/tNumber". Used Property as ResponseAsXml and Path languae as Xpath. Please guide me on how to resolve this. Thank you in advance Re: How to do assertions using using groovy script HiHimanshuTayal, Sorry for the delay in the response. I'm not saving excel file into properties test step. I have an excel file which has a test step name in one column, fields(comma seperated) which we are expecting in the response body in one column. Now in my groovy script I want to read the fields against a particular test step and check if those fields are present my response are not. Re: How to do assertions using using groovy script HiHimanshuTayal, Thank you for your reply. What I'm trying to achieve is I will reading the fields from an excel file and check if they are present in the response or not. For eg: I will be readingcityCode andcityName from a column in excel file. My response is as below: [{ "cityCode": "2345", "cityName": "abc" }] I need to check if bothcityCode andcityName are present in the response or not So the comparison should be dynamic and automatic but not manual How to do assertions using using groovy script Hi, I'm using soapUI for test execution. I want to do contains assertion using groovy script. I want to check if a certain list of fields are present in my response or not. For that I need to use contains assertion and as per the requirement I need to do it through groovy script. Please suggest me on how to achieve it. Thank you in advance Re: Getting corrupted excel file created through groovy script HiHimanshuTayal, Thanks for your reply. I'm not saving my response manually. We need to do this through the groovy script Re: Getting corrupted excel file created through groovy script Hinmrao, Thanks for your reply. As per the requirements, we need to get the response in the report. Getting corrupted excel file created through groovy script Hi , I'm using below script to create a report of my test execution. Since some of my response body has huge size , which cannot be accommodated into an excel cell I have used a logic to just write that "reponse is too big" instead of writing my original response. Whenever my response is huge my report is getting corrupted and some of the data is not getting written to the output file. Please suggest me on how to get this issue resolved. Attached the screenshot of error I'm getting. import static java.nio.charset.StandardCharsets.*; import java.lang.*; import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep import com.eviware.soapui.support.XmlHolder import jxl.* import jxl.write.* import org.skyscreamer.jsonassert.JSONAssert import org.skyscreamer.jsonassert.JSONCompareMode import groovy.json.JsonSlurper def count=0,i=1,j=1,k=1,pass_count=0,fail_count=0 def inputFileName,outputFileName def inputFile = testRunner.testCase.testSuite.getPropertyValue("inputFileName") def outputFile = testRunner.testCase.testSuite.getPropertyValue("outputFileName") def testStep = testRunner.testCase.testSteps["Properties"] Workbook inputWB = Workbook.getWorkbook(new File(inputFile)) Sheet inputSheet = inputWB.getSheet(0) no_of_rows= inputSheet.getRows().toInteger() Workbook existingInputWB=Workbook.getWorkbook(new File(inputFile)) WritableWorkbook outputWB=Workbook.createWorkbook(new File(outputFile),existingInputWB) testCaseName=testRunner.testCase.name outputWB.createSheet(testCaseName,2) WritableSheet sheet_writable = outputWB.getSheet(testCaseName) (0..context.testCase.testStepCount-1).each{ def step = context.testCase.testStepList[it] if ( step instanceof WsdlTestRequestStep) { jxl.write.Label stepName = new jxl.write.Label(0,i ,step.name) sheet_writable.addCell(stepName) def tr=testRunner.testCase.getTestStepByName(step.name) def String endPointUrl= tr.getHttpRequest().getResponse().getURL() jxl.write.Label reqUrl = new jxl.write.Label(2,i ,endPointUrl) sheet_writable.addCell(reqUrl) def payload = context.expand(step.getPropertyValue('Request')) jxl.write.Label reqPayload = new jxl.write.Label(3,i ,payload) sheet_writable.addCell(reqPayload) def response = context.expand(step.getPropertyValue('Response')) if(response.length()<1048576) { jxl.write.Label reqResponse = new jxl.write.Label(4,i ,response) sheet_writable.addCell(reqResponse) } else { log.info "response too big" jxl.write.Label reqResponse = new jxl.write.Label(4,i ,"Response is too big") sheet_writable.addCell(reqResponse) } count=count+1 i=i+1 } } def overall_status=testRunner.testCase.testSuite.getPropertyValue("overallStatus") def TestCase = testRunner.getTestCase() def StepList = TestCase.getTestStepList() StepList.each{ if(it.metaClass.hasProperty(it,'assertionStatus')){ if(it.assertionStatus == AssertionStatus.FAILED){ jxl.write.Label anotherWritableCell10 = new jxl.write.Label(1,j ,"Failed") sheet_writable.addCell(anotherWritableCell10) fail_count=fail_count+1 }else if(it.assertionStatus == AssertionStatus.VALID){ jxl.write.Label anotherWritableCell10 = new jxl.write.Label(1,j ,"Passed") sheet_writable.addCell(anotherWritableCell10) pass_count=pass_count+1 }else if(it.assertionStatus == AssertionStatus.UNKNOWN){ jxl.write.Label anotherWritableCell10 = new jxl.write.Label(1,j ,"UNKNOWN (PROBABLY NOT ALREADY EXECUTED)") sheet_writable.addCell(anotherWritableCell10) } j=j+1 } } if(overall_status=="Passed" && fail_count>0) { testRunner.testCase.testSuite.setPropertyValue("overallStatus","Failed") } outputWB.write() outputWB.close() existingInputWB.close() Appreciate your help in advance. Re: Unable to read response of one rest test step Hinmrao, I didn't understand your point. Can you please eloborate. Thank you Re: Unable to read response of one rest test step Hinmrao, Objective is to read expected output from excel compare it with soapUI response and write the response body, request url, status of test step, test step name to another excel.Code which I have posted is for comparision and it plays the major role Re: Unable to read response of one rest test step Hinmrao, I have compared them and found out . Whenever there is 204 response code, response body will be empty. In that case my json assertion is failing. So I have used if else condition to skip entering json assertion in case of 204 response code. If there is any test step with 204 response code in that scenario it was supposed to enter else part, but its not entering . Can you please suggest me on how to process with this. Thank you in advance