Forum Discussion

pradeepbishnoi's avatar
pradeepbishnoi
Contributor
14 years ago

Beinging with Script Assertions

Hi,

I have written few lines of code so as to read the soapUI response. This can be used as a Script Assertion in the response.

//////////////////////
import org.w3c.dom.NodeList
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Attr
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder ("Test_Case_Name#Response")
holder.namespaces["ns2"] = "http://namespace2"
holder.namespaces["ns1"] = "http://namespace1"
def nodeVariable =holder.getNodeValues("//ns2:A/ns1:B/ns1:C")
log.info("Number of nodes under the node are : " + nodeVariable.length)

def domVariable =holder.getDomNodes("//ns2:A/ns1:B/ns1:C")
log.info(domVariable.length + " - " + domVariable[0]) // domVariable[0] would return the set of node (subnode) under tag C
/////////////////////////
No RepliesBe the first to reply