SoapUI利用Groovy对response与断言的处理
1.对response的处理:(其中Test Request是request的名称)
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def holder = groovyUtils.getXmlHolder( "Test Request#Response" ) log.info(holder.getNodeValue("//sessionid")); def sessionid = holder.getNodeValue("//sessionid") return sessionid
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sam="http://www.soapui.org/sample/"> <soapenv:Header/> <soapenv:Body> <sam:logout> <sessionid>${SessionId#result}</sessionid> </sam:logout> </soapenv:Body> </soapenv:Envelope>
2.对断言的处理:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def holder = groovyUtils.getXmlHolder( "Test Request - logout#Response" ) def sessioninfo = holder.getNodeValue("//sessioninfo") log.info(sessioninfo) assert sessioninfo.equals("OK")
点亮测试人生!QQ:408129370
百度阅读电子书地址:http://yuedu.baidu.com/ebook/f6dbb2a2f01dc281e53af0f3
讨论QQ群:536192476
个人公众号:
百度阅读电子书地址:http://yuedu.baidu.com/ebook/f6dbb2a2f01dc281e53af0f3
讨论QQ群:536192476
个人公众号: