<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Header/> <env:Body> <ns2:getTestResponse> <return startTime="2012-11-26T14:40:31" endTime="2012-11-26T14:40:32"> <ns4:Message status="SENT"/> </return> </ns2:getTestResponse> </env:Body> </env:Envelope>
Как получить атрибут status?
Способ 1.
import com.eviware.soapui.support.XmlHolder; def soapRequest = testRunner.testCase.getTestStepByName("YourTestCase"); //ответ soapRequest'а является property тест-кейса def responseValue = soapRequest.getProperty('Response').getValue(); def parcedResponse = new XmlParser().parseText(responseValue); def getStatus = parcedResponse.depthFirst().grep{it.@status}.'@status'; log.info getStatus[0]
Способ 2.
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def holder = groovyUtils.getXmlHolder( "YourTestCase#Response" ) log.info (holder.getNodeValue('//ns4:Message/@status'));
Комментариев нет:
Отправить комментарий