Ask a Question

excel datasource

Occasional Contributor

excel datasource

dear experts,

I am very new in soapUI. I downloaded 5.4.0-EB and 5.3.0 and I read this documentation ( and tried the steps how to import an excel file through datasource function.

When I try, I do not see any datasources in my "DataSource TestStep" menu to add it. Can you tell me how to do it?

But when I check in the ReadyAPI, it has.

My question is:

1. is it really there is no datasource function in the menu for soapUI? and it is just in the ReadyAPI only?

2. if there is that funcion, do you mind if you can tell me how? because I am curious, why in the docs has, but in my SoapUI does not have it.

Champion Level 2

That step is not part of Open Source edition. And only available via Pro edition.

However, it is possible if you write a groovy script and you should be able to find some example code snippet if you search on the net.

Regular Visitor

You can put this code in the TearDown script of the TestSuite. it will execute every TestCase that has a property called Execute and the value is Yes. Then it will execute each test case with a tes of data that is contained in an excel file. The excel file will have a sheet per testcase, sheet name and test case name should be the same (to be able to identify it) 


import jxl.*
import jxl.write.*

def excelfile = testRunner.testCase.testSuite.project.getPropertyValue( "InputDataExcel" )
def workbook = Workbook.getWorkbook(new File(excelfile.toString()))

def properties = new
def async = false
def my_TestSuite = runner.testSuite
int rows=0; 
int cols=0; 
def End;
def sheet;

for (my_TestCase in my_TestSuite.getTestCaseList())
    if (my_TestCase.getPropertyValue("Execute") == "Yes"){

    		sheet = workbook.getSheet(my_TestCase.getName())
    		my_TestSuite.setPropertyValue( "End", rows.toString())
    		my_TestSuite.setPropertyValue( "RowSelector","1")   
    		my_TestSuite.setPropertyValue( "Cols",cols.toString())
    		End=rows ("TotalRuns:" + End)
 		   def RowSelector = my_TestSuite.getPropertyValue( "RowSelector" ).toInteger()
    		while (RowSelector<End){  properties, async )
			my_TestSuite.setPropertyValue( "RowSelector",RowSelector.toString()) ("TestRun: " + RowSelector)

    my_TestSuite.setPropertyValue( "RowSelector","1")	
    my_TestSuite.setPropertyValue( "End","0")		

Following code could be inserted in the same script or in the setup script of each test case.


import jxl.*
import jxl.write.*

//pull value from test suite properties 
def RowSelector = testRunner.testCase.testSuite.getPropertyValue( "RowSelector" ).toInteger()
def Cols = testRunner.testCase.testSuite.getPropertyValue( "Cols" ).toInteger() ("column "+ Cols + "row" + RowSelector) ("Columna: " + Cols.toString())

//Read Excel
def excelfile = testRunner.testCase.testSuite.project.getPropertyValue( "InputDataExcel" )
Workbook wb = Workbook.getWorkbook(new File(excelfile.toString()))

//creating a copy to save results in
WritableWorkbook copy = Workbook.createWorkbook(new File("C:\\Apps\\Results\\Output.xls"),wb)
File datasheet = new File("C:\\Program Files\\SmartBear\\SoapUI-5.2.1\\bin\\ext\\dataSheets\\ResultTemp.xls")

def key
def value

for (i=0; i<Cols; i++){"i:" + i)
 	key=wb.getSheet(testRunner.testCase.getName()).getCell(i, 0).getContents()
 	value=wb.getSheet(testRunner.testCase.getName()).getCell(i, RowSelector).getContents()
 	testRunner.testCase.setPropertyValue(key.toString(), value.toString())"Key Is: " + key + "value is:" + value);"column "+ Cols + "row" + RowSelector)


Showing results for 
Search instead for 
Did you mean: