Property Transfer from a testcase response to a request in different testcase
Solution 1
IMO the easy way to do so is using the property expansion. For you case you can use the follow notation approach ${Test step name#Response#JSONPath}
.
Supposing you have a first testStep named REST Test Request
with the follow response:
{
"items":[
{"id": "1234","state": "XYZ","type" : "ABCD"},
{"id": "12345","state": "XYZV","type" : "ABCDF"}
]
}
And you want to use the first id
from items
array in a second testStep request and setting it inside array you can use the follow notation:
{
workItemsId: [${REST Test Request#Response#$items[0].id}],
field: "ABCD"
}
UPDATE
If as you comment you want to use the JSONPath
expression in a property transfer, add a Property transfer
testStep, select as source your request, as property response
, as path language JSONPath
then put the expression $items[0].id
and finally select the property where you want to put the result. Finally your property transfer will looks like:
Hope it helps,
Solution 2
Are you using two test cases for this or just two test steps? Anyways, rather than transferring the property directly to next request, you can set it as a property on test case and then use that property in next request with property expansion. So,
- create a property "id" on test case.
- In property transfer step set the value of this property using items[0].id
-
In next request use property expansion to populate the value, so json will look like:
{ workItemsId:["${#TestCase#id}"], field: "ABCD" }
Here are more details about property expansion : https://www.soapui.org/scripting---properties/property-expansion.html
Binoy Cherian
> I like programming and stackoverflow has been of great help to me. > It's time that I create an account and contribute whenever I get > the chance. > > I like Java and am working for a firm in Paris as a Java developer.
Updated on June 04, 2022Comments
-
Binoy Cherian almost 2 years
Testing a
rest
service inSoapUI
, I need to do a property transfer from a testcase response to a request in different test case.JsonResponse in the first testcase is as follows:
{[{ "items":[{ "id": "1234", "state": "XYZ", "type" : "ABCD" }, { "id": "12345", "state": "XYZV", "type" : "ABCDF" } ]}
The id(just one) from the response has to be directed to the Json request of the second testcase via property transfer
{ workItemsId: ["1234"], field: "ABCD" }
I have tried using items[0].id, but that transfers only the value. I need it as an array in the response. Any help would be deeply appreciated. I am so new to SOAP-UI.
-
Binoy Cherian about 8 yearsCan you suggest me to do the same via a property transfer..pls
-
albciff about 8 years@BinoyCherian Sorry I don't understand your comment, do you mean to get the value of your response using jsonpath in
property transfer
? -
SiKing about 8 yearsThe answer is correct. I would just suggest to use
${Test step name#ResponseAsXml#XPath}
instead. The reason being: if you want to run your tests in a CI environment, the SoapUI Maven plugin was not released for version 5.2, which is where JsonPath support was added. I spent all of yesterday rewriting my JsonPath to XPath for this reason. :( -
Binoy Cherian about 8 years@abcif, Yes i would like to get the value of the response using jsonpath in property transfer.