0

I am novice in groovy scripting however trying to get some repetitive work done by automating a generation of an XML file creation.

So the question is:

I have an excel data source step in ready api and i would like to parametrize all values so they are passed to groovy script. At present if i hard code the values in script, XML is formed as per schema however I need to iterate through all data in excel. so my test suite currently contains the following structure:

  1. Data source
  2. Groovy Script
  3. Data Source Loop

I would like my data read each row at a time which will build XML elements as needed. So far I have the following code in script:

//package test

import groovy.xml.MarkupBuilder

/**
 * A Simple Example that builds an XML document.
 */


class Test 
{
    static main(args) 
    {


    def fileWriter = new FileWriter("c:/test.xml")
        def fileBuilder = new MarkupBuilder(fileWriter)

    fileBuilder.Header 
    {



        date ('') 


        Item
            {
                SKU('')
                Description('')
                Amt('')
                Qty('')
            }

     }
       fileWriter.close()

    }

}

Looking forward to hearing from experts on this.

Thanks

cfrick
  • 35,203
  • 6
  • 56
  • 68
sanny
  • 1
  • 2

1 Answers1

0

You don't need a groovy script if you are using Ready API for your task

1) Data Source step :- in Ready API when this step is executed it will populate all the data from excel into Ready API

2) You have to create various properties to use those values. for example :- Description variable will store value from Column1, Example

3) Since you have values stored in step 2 and lets assume your datasource step name is DS, so in your xml you can use variable like ${#DS#Description}

4) finally you will point the Data Source Loop to the second step and not data source loop. So this way everytime description will have a new value and your xml will be run with new values each time Example

Gaurav Khurana
  • 3,423
  • 2
  • 29
  • 38