[SoapUI] 通过正则表达式从xml格式的response中提取ID

 

import com.eviware.soapui.support.GroovyUtils
import java.util.regex.*

 //Get response
def groovyUtils = new GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( "addSecurity#ResponseAsXml" )

//Parse securityId
def data = holder.getNodeValue("//data[1]/text()")
def securityId

Pattern p = ~/securityid=\"\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/
Matcher m = p.matcher(data)

while(m.find()){
	securityId = m.group()
	securityId = securityId.split("\"")[1]
	log.info "the new securityId = "+securityId
	testRunner.testCase.setPropertyValue( "securityID", securityId )
}

  

posted on 2017-04-05 15:26  张缤分  阅读(1611)  评论(0编辑  收藏  举报

导航