Forum Discussion
Hey, this should do it:
// Get the current test case def testCase = testRunner.testCase // Get the desired testStep def testStep = testCase.getTestStepByName("Request1") // Iterate through each parameter testStep.requestProperties.each {
// Log the existing parameters log.info it.getKey() + " : " + it.getValue().getValue() }
// Add a new parameter called 'param3' and assign to it the value 'val3'
testStep.getRestMethod().addProperty( "param3" ).setValue( "val3" )
:catvery-happy:
- shubhimu7 years agoContributor
Lucian. Thanks for this.
My requirement is to take rest request from one test case lets say A and copy the endpoint/resource and parameter of the same in to the rest request placed in another test case B and run the request from B test case.
Ready api has non editable endpoint/resource/parameter. And i can take the end point of rest request from its custom properties. Also i can set it in the another test case rest request but i am not able to get and set resource and parameters.
You provoded the solution to get rest request parameters and add it but can you please provide me some help in getting the resource and how i can set it in another request. Also how i can set rest request parameters in another rest request.
Thanks,
Himanshu
- Radford7 years agoSuper Contributor
I don't know how to do exactly what you are asking and while not the solution you need this might help you on your way, some Groovy which will get the rest resource details:
log.info('REST Test Step Class = ' + testRunner.getTestCase().getTestStepByName('REST Request').getClass()) log.info('Resource Name = ' + testRunner.getTestCase().getTestStepByName('REST Request').getResource().getName()) def xmlBeansRestParamsTestPropertyHolder = testRunner.getTestCase().getTestStepByName('REST Request').getResource().getParams() log.info('xmlBeansRestParamsTestPropertyHolder Class = ' + xmlBeansRestParamsTestPropertyHolder.getClass()) xmlBeansRestParamsTestPropertyHolder.getPropertyList().each(){ restParamsTestProperty -> log.info('----------------------------------------------') log.info('Param Class = ' + restParamsTestProperty.getClass()) log.info('Param Name = ' + restParamsTestProperty.getName()) log.info('Param Style = ' + restParamsTestProperty.getStyle()) log.info('Param Location = ' + restParamsTestProperty.getParamLocation()) log.info('Data Type = ' + restParamsTestProperty.getType().getLocalPart()) }
I assume that you've seen the Ready API JavaDocs? I think this will be a case of looking up the classes in the JavaDocs and trying things out, good luck. Please do post back here if you solve this problem.
Related Content
- 8 years ago
Recent Discussions
- 6 days ago
- 10 days ago