是否可以根据从SoapUI接收的响应xml直接通过groovy脚本更新属性文件?
我尝试了以下步骤
def ui = com.eviware.soapui.support.UISupport
def responseAsXml = context.expand( '${Simple Search - Request 1#ResponseAsXml}')
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
def holder = groovyUtils.getXmlHolder(responseAsXml);
def formataddress = holder.getNodeValues("//result//formatted_address");
props = new java.util.Properties();
props.load( new FileInputStream('testProps.properties') );
def sQA_PROP_LOCATION = props.getProperty('QA_PROP_LOCATION');
基本上我需要更新QA_PROP_LOCATION
文件中的abc.property
属性值,其中formatted_address
节点值为响应xml
响应XML如下所示
<GeocodeResponse>
<status>OK</status>
<result>
<type>locality</type>
<type>political</type>
<formatted_address>Rio de Janeiro, Brazil</formatted_address>
<address_component>
<long_name>Rio de Janeiro</long_name>
<short_name>Rio de Janeiro</short_name>
<type>locality</type>
<type>political</type>
</address_component>
<address_component>
............
干杯