Ask a Question

HTTP Request test step - dynamic url update from previous test step response url property value?

SOLVED
SmartFace
Occasional Contributor

HTTP Request test step - dynamic url update from previous test step response url property value?

Please, could someone help me with updating HTTP Request test step url automatically with the value from the previous REST Request test step response?

12 REPLIES 12
Lucian
Community Hero

I will help you with that. Just let me know how the response looks like so I know how we can extract the url. Smiley Happy



If my answer helped please click on the 'Accept as Solution' button.
SmartFace
Occasional Contributor

{
"applicationResponse" : {
"header" : {
"status" : "OK"
},
"response" : {
"state" : "WAITING",
"url" : "https://test.3dsecure.gpwebpay.com/csob/order.do?MERCHANTNUMBER=53270203&OPERATION=CREATE_ORDER&ORDE..."
}
},
"errorCode" : 0,
"macToken" : "nlbyrLHXBF",
"serverContacted" : true
}

Can you set up a property transfer step to pull that from the respose and store it in a properties step? Then you can set the URL of the next test step to ${Properties#ResponseURL} to reference the URL with property expansion. That might be the easiest way, or you can get a bit more complex with groovy.




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!

The following steps can be taken to achieve your goal:

 

1. Click on the test case from where your request is extracted;

2. Add a custom property called 'Url' (see below picture);

 

 2018-06-28_16h03_02.png

 

3. Add a Property Transfer test step in your test case;

4. Click on the Property Transfer step and configure it like shown in the image below. The source step is the step from where you want the url to be extracted.

 

2018-06-28_16h06_28.png

 

Now the url can be used in other requests. In order to do it just write this instead of the normal url: ${#TestCase#Url}

 

2018-06-28_16h08_33.png



If my answer helped please click on the 'Accept as Solution' button.
SmartFace
Occasional Contributor

A property transfer step works well. Trouble is with the HTTP Request step. The Run button (green triangle) is grey.

Can we see a screenshot of the step you are referencing the URL in so we can double check it? And of the property transfer step too. The more details we can see the better. 🙂 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!

Click on the HTTP test step and look into the navigation bar for 'HTTP Request Properties'. Look for the 'Endpoint' property and make sure the value is not empty.



If my answer helped please click on the 'Accept as Solution' button.
SmartFace
Occasional Contributor

Property Transfer works the same way in my SoapUI, but HTTP Request does not work the way you demonstrate. Weird! I use ReadyAPI 2.4.0 version SoapUI Pro. When I put ${#TestCase#Url} into the "Request url" field, I cannot run the HTTP Request. It says there is no url, see in the pictures!TestCaseCustomPropertyUrlTestCaseCustomPropertyUrl

 

HTTPRequestEditorHTTPRequestEditor

 

HTTPRequestNoEndpointHTTPRequestNoEndpoint

 

 

 

So this is one of those instances where the required test step (HTTP request) does not appear to support property expansion. You could put in a groovy script test step that sets the endpoint from the URL in the test case. I am not directly sure if that's possible, but I am looking into it.

 

UPDATE: Of course I found the answer after I posted. Try putting this into a groovy test step:

 

def URL = context.expand( '${#TestCase#URL}' )

context.testCase.testSteps["HTTP Request"].setPropertyValue("EndPoint", URL);



---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
cancel
Showing results for 
Search instead for 
Did you mean: