System.getProperty('user.dir') return wrong directory path

I discovered that if i execute the test in GUI and command mode the Katalon return different directory path to me when i use System.getProperty(‘user.dir’).

**Run in GUI
**System.getProperty(‘user.dir’) is C:\QA\TestCase\Katalon\ABC

**Run in command **
**katalon -noSplash -runMode=console -consoleLog -noExit -projectPath=“C:\QA\TestCase\Katalon\ABC\ABC.prj” -retry=0 -testSuitePath=“Test Suites/Chrome/TS1” -executionProfile=“default” -browserType=“Chrome”
**

Request sent successfully.

System.getProperty(‘user.dir’) is C:\Katalon_Studio_Windows_64-5.4

--------------------------------------------------------------------------------

Test Suites/Chrome/TS1 - Chrome - 20180524_100047…1/1(100%)

--------------------------------------------------------------------------------

No mystery.

As described in https://stackoverflow.com/questions/16239130/java-user-dir-property-what-exactly-does-it-mean, Java ‘user.dir’ means the current working directory.

When run in Katalon Studio GUI, the current directory would be the directory where your project is located.

When run in Console mode, the current directory would be … where? Not documented in https://docs.katalon.com/display/KD/Console+Mode+Execution. I suppose that the current working dicrectory is set to the directory where Katalon Studio is installed.

1 Like

OK, this post can be removed. I’ve resolved the problem

Hi, just curious what you did to resolve the problem? Thanks!

What do you want to achieve with regards to System.getProperty("user.dir") ? Please state what is your problem. Then I would be able to answer to it.

HI Matthew,

You can use this to resolve your problem, this will always return the right path no matter you execute in command prompt or from Katalon IDE.

RunConfiguration.getProjectDir()

3 Likes

Thanks, I got same problem and solved now using RunConfiguration.getProjectDir() with Import
import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration

1 Like