Let me show you an example. I used Katalon Studio v9.0.0 Free version.
I launched Katalon Studio v9.0.0 by double-cliking the desktop icon. I wrote a test case:
println Sysmte.getenv('PATH')
I ran it. I got an output in the console:
2024-08-22 14:00:29.689 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2024-08-22 14:00:29.693 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/TC3
2024-08-22 14:00:30.470 DEBUG testcase.TC3 - 1: println(System.getenv("PATH"))
/usr/bin:/bin:/usr/sbin:/sbin
2024-08-22 14:00:30.533 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/TC3
The value of “PATH” environment variable was very short.
/usr/bin:/bin:/usr/sbin:/sbin
On the other had, in the Terminal window with Bash interpreter I executed a shell command
$ echo $PATH
It showed a very long string value as the following screenshot shows
Another case, in the Terminal window, in the bash shell interaction, I launched Katalon Studio from command line. I ran the same test case as above.
This time I could see a very long string values as “PATH”
This experiments tells us that
System.getenv("PATH")
returned different values in the following 2 cases:
- when Katalon Studio was launched by double-clicking the desktop icon
- when Katalon Studio was launched by commandline interpreter (bash)
How come these 2 cases differs?
The key factors are Bash
, .bash-profile
and .bashrc
In the 2nd case, the bash interpreter forks a new OS process in which Katalon Studio runs. Usually bash executes the .bash-profile
shell script and the .bashrc
shell script on its startup. These shell scripts build up the PATH environment variables with a lot of custom path information. Therefore in the 2nd case, a call to System.getenv("PATH")
you will get a rich value.
In the 1st case, on the other hand, a new process will be forked by macOS without bash. macOS won’t execute .bash-profile
and .bashrc
. Therefore, you will find the PATH environment variable is — how should I express it? — plain.
This behavior doesn’t depend on the version of Katalon Studio. v9.6.0 will work the same as v9.0.0.