Marwa Abdelgawad Marwa Abdelgawad - 4 months ago 34
Groovy Question

Creating automatic folder and files in soapui

I wrote a groovy script in soapui to create files in certain location in my pc. How can I make it dynamic and enable the user to write the location the files are saved to by write the location in configuration file imported at test suite level.

if(context.expand('${#Project#ProduceReports}') == 'true') {
def resultDir = new File("D:\\Reports");
if(!resultDir.exists()) {
def resultsFile = new File(resultDir, "CSVReport.csv");


If you want to get the path from a testSuite property, you can do it as you do with the project property, using context.expand:

def yourPath = context.expand('${#TestSuite#pathDirectory}')

Or alternatively you can do the same with:

def yourPath = context.testCase.testSuite.getPropertyValue('pathDirectory')

Maybe this is out of scope for your question, but could be helpful. If you need you can also use UISupport to ask the user to enter the path he wants with the follow code:

def ui =;
// the prompt question, title, and default value
def path = ui.prompt("Enter the path","Title","/base/path"); path

This shows:

enter image description here