Contributions
Re: Need help re-using a response item in other tests
Your solution should work. If you have multiple steps in your testcase it can be cumbersome to add the token for each step. My solution adds the token to each step so you don't have to take care of of anymore. Use the solution that works best for you. Happy testing!6 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.8KViews0likes0CommentsRe: Need help re-using a response item in other tests
I Solved this by creating a groovy script that sets the payload for all teststeps. My script is as follows: import com.eviware.soapui.support.XmlHolder import groovy.json.JsonSlurper import com.eviware.soapui.support.types.StringToStringMap //get response from "Get Token" step (token) def token = context.expand( '${Get Token#Response}' ).toString() def slurper = new JsonSlurper() def json = slurper.parseText(token) //log.info json.access_token //construct accessToken accessToken = json.token_type + " " + json.access_token //set header for Login step def header = new StringToStringMap() header.put("authorization", accessToken) //set accessToken in each rest call testRunner.testCase.testSteps.each { if (it.getValue().config.type.equals("restrequest") || it.getValue().config.type.equals("request")) { it.getValue().getHttpRequest().setRequestHeaders(header) } } //construct payload for Login step def refresh_token = json.refresh_token //log.info json.refresh_token def payload = '{"refreshToken":"' + json.refresh_token + '"}' testRunner.testCase.getTestStepByName("Login").setPropertyValue('Request',payload)6 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.8KViews0likes4Comments