Forum Discussion
4 Replies
- priyanshuOccasional ContributorYes you can do it in following steps:
1.On test case level,go to setup script and write the code to load the data in custom property of test case level e.g.
def myRequest=new File("Location of Your xml file").getText()
testRunner.testCase.setPropertyValue( "Request", myRequest )
2.Use a transfer property step to transfer the this data into your required step.You can transfer the complete data into request section of step.There is no need of selecting xpath in propety transfer.- AshvneNew Contributor
Thanks for the answer .Can you please show it in the code how to load a xml file from folder in soap ui using groovy scripting.
Thanks in advance
- ChrisAContributor
Hi,
Is this related to the question posted on StackOverflow recently? how-to-copy-a-request-in-soapui-to-a-folder-using-groovy/46542756#46542756
I answered something similar to this on StackOverflow recently....
The below flow is an example of writing the request to a file and then pulling it back in to another request.
Step 1 - Some REST request
Step 2 - Copy the Raw Request value from Step 1 to file
Step 3 - Load the Raw Request from file
Step 4 - Run REST Request with payload form file
Contents of 'Request Copy - Groovy Script'
def rawRequest = context.expand( '${REST Test Request#RawRequest}' ) def file1 = new File('c:/temp/groovy1.txt');file1.write (rawRequest); return rawRequest;
Contents of 'Load Saved Request from File - Groovy Script'. All this does is 'return' a string.
def file1 = new File('c:/temp/groovy1.txt'); return file1.text;
In the final step, I deleted the existing payload in the request section and added a call to the load Groovy script.
Chris
Related Content
Recent Discussions
- 4 days agominhng