Road to data driven testing in SoapUI from csv file

In this post I will show you how to execute SoapUI test for a set of values. For this I have put all data in csv file. I write groovy scripts for reading data from csv and executing the test steps.
Below is the groovy script for reading data from “URL.csv” file where I put all user credentials.

def groovyUtils = new

def csvFilePath = "D:\\URL.csv"
context.fileReader = new BufferedReader(new FileReader(csvFilePath))

rowsData = context.fileReader.readLines()
int rowsize = rowsData.size()

for(int i =0;  I < rowsize;  i++)

    rowdata = rowsData[i]
    String[] data = rowdata.split(",") data[1]
    groovyUtils.setPropertyValue("Login", "UserName", data[0])
    groovyUtils.setPropertyValue("Login", "Pass", data[1])
    testRunner.runTestStepByName( "Login")  

In above code I read data from “URL.csv” file and pass user name and password into “UserName “ and “Pass” of Login steps parameters.
“Login”  test step executed by using test runner for every data.


  1. Good work! I read lot many blogs gone through many tutorials and finally your script helped me!!! Great work!!!

  2. Could you also post the script for reading values from excel and database? If the REST request is of type POST and you are sending a XML body in which the child elements are dynamic and I wanted to make these values dynamically read from an .csv, excel and databases.

    e.g. If I want to read values for the sku1,sku2 and add from SINGLE .csv file or excel and database(sqlserver). Could you please provide scripts for this scenario

    Rest Request:{locale}/{query2}

    1. Below post's link is reading data from xls file in SoaupUI using groovy script:

    2. can we parameterize values from script written in mock response dispatch method using above script to configure diffrent mock responses for those values.pls provide solution..

  3. Great post, helped me a great deal!

  4. The last line in my csv file is read twice and two requests are posted for the same data

  5. Can u please share the groovy script to dynamically add element or complex elements to soap request. This is to manage a collection of elements within a wrapper element

  6. Your blog seems simple to understand therefore i have faith that you will be able to help me out with my problem. can you please help me with ,
    I have a url to where i need to login
    then need to provide product id which will be fetched from .csv file
    click on a link so it produce 100 lines of json code for product information copy it and
    use it inside SoapUI request as it is and get response from which i need to store 5 values in external data source(.xlsx) so i can use that data to produce customized report.

    I am new to rest web service(json request) automation can you guide me in right direction?

  7. This comment has been removed by the author.

  8. Using this code i am able to fetch the data from .csv file and see it in log output of groovy script, but how should i call this data in the Login Teststep(Rest service) I used ${#TestCase#UserName} but this didn't work.

  9. Hi I want to read a .csv file say Test.csv which have names . I want to read and pass the values to the request one by one to the request , so that for each name it generates a new instance.
    Using the above code only one value passes to the request.
    Can i get a little help how to pass those values in a loop

  10. iam getting this exception, can u pls provide some inputs

    groovy.lang.MissingMethodException: No signature of method: is applicable for argument types: (java.lang.String, java.lang.String, java.lang.String, java.lang.String) values: [clientId, subjectId, testCfg, 07687] Possible solutions: setPropertyValue(java.lang.String, java.lang.String, java.lang.String) error at line: 16


Leave your comments, queries, suggestion I will try to provide solution