cancel
Showing results for 
Search instead for 
Did you mean: 

Update XML request in another test case

ramyaas
New Contributor

Update XML request in another test case

I am having 2 test cases in my suite.
First test case contains 1 test step with xml request.
Second test case contains 1 test step with groovy script. I want to run the 1st test case from this groovy script a number of times. Every time I want to change the input XML. I am unable to update the input XML in TestCase 1.
I have the following the code for the groovy script:

import com.eviware.soapui.support.XmlHolder
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
def tsuite = testRunner.testCase.testSuite
def acctInq_tstepName = tsuite.getTestCaseAt(1).getTestStepAt(0).getName()
def acctInq_requestHolder = tsuite.getTestCaseAt(1).testSteps[acctInq_tstepName].testRequest.getRequestContent()
def acctInq_req = groovyUtils.getXmlHolder("$acctInq_requestHolder")
acctInq_req["//soapenv:Envelope[1]/soapenv:Body[1]/v2:AcctInqRq[1]/ifx:DepAcctId[1]/ifx:AcctId[1]"] = "0009917812344"
acctInq_req.updateProperty()

I also tried using
tstep.setPropertyValue("request",cStr(acctInq_req))

In either case the XML is not getting updated. Please help.
1 REPLY 1
TesterNo1
Contributor

Re: Update XML request in another test case

def TargetTestcase=testRunner.testCase.testSuite.project.getTestSuiteByName(CalleeSuite).getTestCaseByName(CalleeTestCase)

 

def step = TargetTestcase.getTestStepByName("Features Lookup Call").getProperty('request').value
holder = groovyUtils.getXmlHolder(step)
//holder.setNodeValue("//ns1:Id", "CNT=0:CNTID=0048")
//holder.setNodeValue("//ns1:description", "0 Month")
holder.setNodeValue("//ns1:Id","CNT=2:CNTID=0012")
holder.setNodeValue("//ns1:description","24 Months")

holder.updateProperty()
String tmpRequest=holder.getPrettyXml()
TargetTestcase.getTestStepByName("Features Lookup Call").setPropertyValue('request',tmpRequest)

 

 

Do it this way and it should work 

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors