Although, this problem can be solved manually, it's not a very elegant solution. Luckily, we can solve this quite easily with soapUI Groovy scripting feature.
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) // Run the first request and get the response def firstResponse = testRunner.runTestStepByName("Test Case 1") def holder = groovyUtils.getXmlHolder(firstResponse.responseContent) def txnNumber = holder["//NS1:InsertionResponse/NS1:TransactionNumber"] // Modify the second request using the first response def secondRequest = testRunner.testCase.getTestStepByName("Test Case 2") def property = secondRequest.getProperty("request") holder = groovyUtils.getXmlHolder(property.value) holder.put("//NS1:QueryRequest/NS1:TransactionNumber", txnNumber) property.setValue(holder.prettyXml) // Run the second request and get the response def secondResponse = testRunner.runTestStepByName("Test Case 2") holder = groovyUtils.getXmlHolder(secondResponse.responseContent)
Thanks for this post. I have a problem in making my script library working..Can you give some tips?
ReplyDeleteWhat jar files do I need to place in classpath to compile Groovy classes placed in /bin/script folder?