Search code examples
groovysoapui

Get desktop path with groovy


I'm automating a SoapUI project with Groovy that generate and excel report at the end with the results of my requests.

My problem is that I want to get the desktop path in which the file will be saved.

Something similar to this java code, but in Groovy :

String userHomeFolder = System.getProperty("user.home") + "/Desktop";

Thanks in advance !


Solution

  • To get your desktop path in Groovy you can use your Java code directly, since it works perfectly:

    String userHomeFolder = System.getProperty("user.home") + "/Desktop";
    

    If you want an alternative a Groovy way to do so could be:

    String userHomeFolder = System.properties['user.home'] + "/Desktop"
    

    Or:

    String userHomeFolder = System.properties.'user.home' + "/Desktop"
    

    All of this gets the same result.