[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 )
}

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM