Forum Discussion

vivram's avatar
vivram
Occasional Contributor
7 years ago

Data Driven using SoapUI Open Source

Hi Guys,

 

I am using SoapUI free version tool.

 

I want to use a data driven testing having the below scenario:

 

1. Load the parameter from an excel sheet to Test Case

2. Write back the response parameter to the respective excel sheet

 

I have seen some posts using groovy script, but didn't find how to write back the response values to excel sheet.

 

Thanks

4 Replies

  • Lucian's avatar
    Lucian
    Community Hero

    Can you give some more info? What do you mean by 'response parameter'? Where do you want to write it in the excel?

    • vivram's avatar
      vivram
      Occasional Contributor

      I want a specific response xml value from the payload to be stored back in excel sheet for each of the input values supplied through looping.

       

      The response values need not write on same excel sheet in which Input values are supplied, but could be different one. Would be easier if it's on same excel sheet. looking to print in any column of excel sheet 

       

      Thanks

  • vivram's avatar
    vivram
    Occasional Contributor

    I was able to successfully create inputs via external file and using counter

     

    check this link

    https://learnsoapui.wordpress.com/2012/05/19/groovy-datasource-teststep-dataloop-teststep-using-groovy-in-soapui/

     

    Haven't got my luck to get groovy script to record specific value of respnonse xml to an external file. Challenge is to record in looper. As I want to store each response in next line of xls file or .txt file.

     

    eg. want to record the below value of xml to external file with each response in new line

     

    <ns2:cost>1953.44</ns2:cost>

     

    Thanks

  • vivram's avatar
    vivram
    Occasional Contributor

    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