Forum Discussion
Have cracked this Groovy Script for writing back response value to external file. Works well :smileyhappy:
If your response xml looks like below:
<ns2:About>
<ns2:make>Samsung</ns2:make>
<ns2:model>S5</ns2:model>
<ns2:cost>589.62</ns2:cost>
</ns2:About>
The below groovy script does the following actions
1. Captures the xml response for test case
2. Captures the xml node values with 'Cost' element
3. Writes into a file and prints each results in next line (useful for looping) where we want to capture each results in next line
def retrieve = groovyUtils.getXmlHolder("TestCaseName#Response" )
def cost = retrieve.getNodeValues("//ns2:Cost").toString()
new File( "C:/Projects/results.txt" ).append( cost + "\n")
// You could view the value in log output if you want to
log.info cost
Related Content
Recent Discussions
- 6 days agoemoya