Marwa Abdelgawad Marwa Abdelgawad - 1 year ago 161
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");

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download