문제

I am starting to evaluate SoapUI as my test suite, but the Property Transfer thing is really holding me back. I've read a lot of articles about it, but I could not find a way to make it work in my case.

My source is a POST request. This POST request returns me a JSON. I need to pass one of the values of this JSON to the next test.

My response is this:

<Response xmlns="https://localhost/authorize">
    <access_token>4a00c67e</access_token>
   <refresh_token></refresh_token>
   <scope>auth</scope>
   <token_type>online</token_type>
</Response>

I need to get the <access_token> and pass it to the next test as a parameter.

What should I write in the SOURCE and TARGET boxes to get this to work? Why is it so complicated and why there is no easy to understand tutorial about this? :(

도움이 되었습니까?

해결책 4

The simplest way to do that, for me, was using "Property: Response" and "Path Language: JSONPath".

Then for the source I used simply "$.access_token"

For the Target, I defined a Property called access_token in the Project.

다른 팁

To add to what Abhishek said. If you only need the access_token you would use the following XPath:

declare namespace var="https://localhost/authorize";
//var:Response/var:access_token

In the property transfer step you source would be the step from where you want to get the data, in the source property select response.

In the space below source put //access_token this will extract the value of the access_token and make it available for transfer. if you do not provide the xpath soapUI will provide the whole response xml for transfer.

Your target would be the step where you want to set the extracted property, <access_token> in your case. The property would be the property to which you want to set the extracted value.

Important place your property transfer step after the source step. Execution in soapUI is top down and if property transfer is placed before the source step you will not have any value to transfer.

To give you an example soapUI property transfer step

In this example i have a test request called SourceRequest whose response will be transferred to a test suite level property called aa. As you can see here. I have given my property transfer a name PropertyTransferName(it can be anything you want). In the source I have mentioned my source request and property as Response. As I am going to save the whole response in a test suite level property, I have mentioned my test suite as the target and given the name of the property to which i want to transfer.

In this i could have parsed the response of my source property by giving an xpath like you need to do.

Hope this helps.

For the "Source" x-path use:

**//*[local-name()='access_token']**

select "Transfer text content"

select "Use XQuery"

This should extract the text content from your access_token node.

To transfer property, it is important to know whether the response type (from where you are transferring value) is json or xml. In case it is json, as in screenshot below:

enter image description here

make sure to set property as "ResponseAsXml" in transfer property window as below:

enter image description here

else "Response" will do the needful.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top