In Ready API, I want to perform data/ values comparison of a xml-file on my system with xml response of a rest API call? Can someone help or knows how to resolve the issue step by step?
Thanks.
Hi Rao-
Thanks for your response, appreciated. Here is the detail which may help you to understand.
I’m trying to compare the whole XML file from my hard drive with the XML response of a rest API call. I want to know how to get this done step by step in Ready API. If there is a groovy script, then what values need to be changed to what in the groovy script to perform this comparison.
Thanks,
Ray
As you have mentioned that you are looking for an alternative to Groovy, here is a suggestion (Note: This will only work if the file containing the XML data on your hard drive is identical):
1) First use a File Wait test step to pick up the file.
2) Run your REST request test step.
3) Within your REST request use a Message Content Assertion to compare the result of your API call with the contents of the file.
The key thing to note here is that the file Wait test step provides the contents of the file as a variable "fileContents" (review the above linked doc page). This can be accessed from another test step via a property expansion, if you are unsure about these you can use the point and click Get Data functionality.
If your XML file is not exactly identical (for example it contains todays date), then as @nmrao mentioned you can use xmlunit, but this does involve installing 3rd party libraries and using Groovy, here's a link to a post I made previously about it:
nmrao, Radford, thanks a lot!
@API_Tester hi! Did you have a chance to see if the suggestions work?
Subject | Author | Latest Post |
---|---|---|