[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