extract xml node value from a response in script assertion
Hi All
Hi have a xpath match assertion that is working perfection as below
declare namespace ns1='http://${#Project#EndpointIP}/Subscription/V1/${DataSource#id_Request}';
//ns1:ATTRIBUTES//child::ns1:NAME [text() = ‘Result']//following-sibling::ns1:VALUE
Now I want to convert it to script typed assertion, the value of Result node is stored in variable named addResult as below
The problem I have here is that the addResult is always null. And the assertion is always false. Not sure why. Can anyone help me to show where it is wrong?
Here is my code
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def responseHolder = groovyUtils.getXmlHolder( messageExchange.responseContentAsXml.toString())
responseHolder.namespaces["ns1"] = "http://" + context.expand("Project#EndpointIP") + "/SUBSCRIBER/V1/" + context.expand( '${DataSource#id_Request}' )
def addResult = responseHolder.getNodeValue("//ns1:ATTRIBUTES//child::ns1:NAME [text() = ‘Result']//following-sibling::ns1:VALUE")
if (addResult == context.expand( '${DataSource#IDRequest_RESPONSE}' )){
log.info "matching here ->" + addResult
assert true
}else{
log.info "Not matching here ->" + addResult
assert false
}
natashanguyen42, I see you contacted the Support Team, and they are waiting for additional info from you. Please share the solution with us when you have it :smileyhappy:
Thank you!