Tranfert part of a header response as a property
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tranfert part of a header response as a property
Hello, I'm in front of something new and I don't know how to solve it.
I have a step case where I get this raw response :
HTTP/1.1 204 No Content
Server: Apache-Coyote/1.1
Location: identifiers/0000000004
Date: Wed, 14 Sep 2016 15:05:00 GMT
Connection: close
What I want to do is to take the identifier, here "0000000004", after "identifiers/" of the header "Location" and transfer it to another test case further.
How can I do that ?
Thank you very much,
Julian
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Julian,
It sounds like the Property Transfer TestStep is what you need. Take a look at this article:
http://readyapi.smartbear.com/structure/steps/property/transfer/intro/start
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Tanya,
I'm trying to use the Property Transfer TestStep but I don't see any solution to catch a part of the header response in the tutorial.
Thank you.
Julian
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would suggest to use Script Assertion over Property Transfer test step. i.e., Add the script assertion to the request step and remove property transfer step altogether.
The below script would read the given header, trims the required value and set that value at test suite level, so that all the remaining test cases can use that location value.
//If you need it for another header, please change the value of key below
def key = 'Location' if (messageExchange.responseHeaders.containsKey(key)) { def result = messageExchange.responseHeaders[key] def locationValue = result[0].replaceFirst(~/\w+\//,'') log.info "Setting the location value ${locationValue} at suite level" context.testCase.testSuite.setPropertyValue('LOCATION_VALUE', locationValue) } else { log.error "Response does not contain header : ${key}" }
In the following test cases use location as given below:
- If the step is request step (soap / rest etc.,), use ${#TestSuite#LOCATION_VALUE}
- If the step is of groovy script step, use context.expand('${#TestSuite#LOCATION_VALUE}')
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much, that's what I needed.
Julian
