A Datatransfer teststep allows you to query results from SOAP teststeps (request and response) and store them in a variable. This is helpful in cases where you need to establish a set of requests where the input of a request is part of the response of the previous teststep.
See create teststeps, how to create a Datatransfer teststep.
When you create a Datatransfer teststep and select it in the Teststep list view, the following editor appears
.We will create an XPath datatransfer (value provider) with a namespace-aware XPath expression. Be aware that we will use the request for this XPath expression. In general, you may use the response for your query
.To make this work, you need to walk through our getting started tutorial. Once you are done, you need to change the request as follows:
We will query the value of msg:Element and store it in a testcase variable
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header></soapenv:Header> <soapenv:Body> <msg:Enumerate xmlns:msg="http://schemas.xmlsoap.org/ws/2004/09/enumeration"> <!-- continue here --> <msg:Element>USD</msg:Element> </msg:Enumerate> </soapenv:Body> </soapenv:Envelope>
Click with your mouse on the button create new XPath expression. This will open a dialog. Enter the name currency and confirm with ok. You will see the new datatransfer value provider in the list.
Click with your mouse on the teststep Enumerate. This will link the teststep with the value provider and display the following view:
We need to reference the request for our walkthrough. For this reason the screenshot displays the value request after change from the default as the input type of the value provider.
We enter a simple, namespace aware XPath-Expression.
//msg:Element/text()
Now, we run this XPath expression and will get an error message
Click with your mouse on the button run XPath value provider
This will show an error message.
The reason for the error message is an unsatisfied mapping from the prefix to the namespace. This can be resolved very easily. Click on the button remove error message as we don't need this error message.
Switch to to the tab Namspaces and click with your mouse on the button preset namespaces from input teststep
This will load the namespaced defined in the input XML (request) with the prefixes used in the XML.
You may run the XPath expression again, and will get error message that no variable has been loaded.
Create your own testcase variable currency. In case you're uncertain, how to proceed, see Create a VariableValueTransfer. Then run the value provider again. The result should be as follows: