Forum Discussion

ramyaas's avatar
ramyaas
New Contributor
12 years ago

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

  • 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