Saturday, October 31, 2015

API testing: SoapUI property transfer using Groovy scripting

//Importing XML module of SoapUI tool
import com.eviware.soapui.support.XmlHolder



//Access the Get_Employee Response XML and get the value of name tag.
def response=context.expand('${GetEmployee#response}')
def xml=new XmlHolder(response)
def namenode = xml.getNodeValue("//ns:name")
log.info namenode
context.setProperty("name","$namenode")
log.info context.getProperty("name")

//Access the Delete Employee Request XML and store the value grabbed from the Get Employee Response
def requestt = context.expand('${DeleteEmployee#request}')
def xmlreq=new XmlHolder(requestt)
xmlreq.setNodeValue("//typ:guestName", namenode)

//Formatting the xml and put it in the Testcase, Teststeps level 
def dxml = xmlreq.getXml()
testRunner.testCase.testSteps["DeleteEmployee"].setPropertyValue("request",dxml)

2 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete