soapUI - embbed XML in a request using groovy

前提是你 提交于 2020-01-23 17:02:33

问题


I'm making test cases on soapUI, on some steps I would use a REST quest and put XML code in the lower pane, something like

<dataList>
    <data>
        3.1416
    </data>
    <data>
       5.11
    </data>
</dataList>

But I need to get the response and store the results that will be contained inside the XML text of the response, to verify that the web service is executing proper operations and then send more requests using the received results.

Thanks everyone!


回答1:


I could solve this using properties and Property Transfer

  1. Add a property to the TestCase in the Custom Properties tab

  2. Add a property Transfer step

    2.1 As source select the test step with the response where are the results to store

    2.2 In the drop down list of property select ResponseAsXml

    2.3 In text are of the source write the path of the xml tag like: /dataList/data

    2.4 As target select the test case where was added the custom property of (1)

    2.5 As target property select the name of the custom property added.

Thank you very much to everyone for your prompt answers :) As soon as I have better reputation I'll post some pictures.




回答2:


A Groovy script test step which goes with your test suite as below:

def grUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = grUtils.getXmlHolder(
               context.expand('${TestStep#Response#//node}'))

println holder.getXml()

//where TestStep = Your test Step where you get the response  
//node = The xml node you want to pick. In your case it is "dataList"


来源:https://stackoverflow.com/questions/18539805/soapui-embbed-xml-in-a-request-using-groovy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!