Katalon.properties file and JVM System Property katalon.user.home


#21

console.properties? — it is generated by Katalon studio, and nothing to do with what I call “katalon.properties”.


#22

Alex,

I am afraid you haven’t check “How to” sections in the README of https://github.com/kazurayam/KatalonPropertiesDemo
Please read it first and try again.


#23

kazurayam said:

Alex,

I am afraid you haven’t check “How to” sections in the README of https://github.com/kazurayam/KatalonPropertiesDemo
Please read it first and try again.

sorry for my bad english.
I tried using your KatalonPropertiesDemo repository, it’s run well if I run with open katalon GUI, but it’s failed when I tried to execute via command line.
I execute like this:

$cd /Applications/$set GlobalVariable.hostname=test
$./Katalon\ Studio.app/Contents/MacOS/katalon --args -noSplash  -runMode=console -consoleLog -projectPath="/Users/automation-web/Automation-Web.prj" -retry=0 -testSuiteCollectionPath="Test Suites/TestSuiteCollection/Run Smoke Test 1(Chrome)"

This are for logs:



10-09-2018 04:28:03 PM - [RUN_DATA] - Logging run data 'hostName' with value 'btpn - 10.10.24.118'10-09-2018 04:28:03 PM - [INFO]   - >>> GlobalVariable.hostname default value: ''10-09-2018 04:28:03 PM - [END]    - End action : comment10-09-2018 04:28:03 PM - [START]  - Start action : Statement - preferedHostname = props.getProperty("GlobalVariable.hostname")10-09-2018 04:28:03 PM - [END]    - End action : Statement - preferedHostname = props.getProperty("GlobalVariable.hostname")10-09-2018 04:28:03 PM - [START]  - Start action : Statement - If (preferedHostname != null)10-09-2018 04:28:03 PM - [END]    - End action : Statement - If (preferedHostname != null)10-09-2018 04:28:03 PM - [START]  - Start action : Statement - Else10-09-2018 04:28:03 PM - [START]  - Start action : comment10-09-2018 04:28:03 PM - [INFO]   - >>> GlobalVariable.hostname stays unchanged

it’s looks like the value not inserted into GlobalVariable.hostname


#24

Alex,

You happened to point out a weak point of the MultiSourcedProperties-1.0.jar. Thank you.

-------

As https://github.com/kazurayam/KatalonPropertiesDemo explains: you create katalon.properties file in java.util.Properties format. The file can be located in various locations as the following list shows. If a single Property is declared in multiple katalon.properties files at different locations, the last wins:

  1. <current directory>/katalon.properties is loaded if exists
  2. $HOME/katalon.properties on Mac/Linux, %USERPROFILE%\katalon.properties on Windows is loaded if exists
  3. If environment variable KATALON_USER_HOME is given, then a katalon.properties file under the directory new File(System.getenv('KATALON_USER_HOME')) is searched and loaded
  4. If JVM System Property katalon.user.home is given, then a katalon.properties file under the directory new File(System.getProperty("katalon.user.home")) is searched and loaded.

When you run a project with Katalon Studio GUI, the will be same as -projectPath="<katalon project dir>". In this situation, your <katalon project dir>/katalon.properties file will be found by com.kazurayam.MultiSourcedProperties object running in the GUI.

But when you run in console mode, you are required to move the current directory to the Katalon installation directory, so you will do $ cd /Applications/Katalon\ Studio.app/Contents/MacOS. This causes the current directory to be moved. In this situation com.kazurayam.MultiSourceProperties object running in the console mode fails to find the <katalon project dir>/katalon.properties file as <current directory>/katalon.properties.

-----------

You have a workaround. Please do as follows:

$ set KATALON_USER_HOME=<katalon project dir>$ cd /Applications/Katalon\ Studio.app/Contents/MacOS$ ./katalon -runMode=console ....

#25

Maybe I’m a little late in this discussion - or I missed or misunderstand something, then please excuse me. :slight_smile: But is there actually a certain reason why you don’t want to use the profile function built into Katalon Studio the way it is supposed to for the quite simple purpose of @Said A… and @Alex Jack to exchange a url when calling it via command line? You can simply create different profiles, each with a different url string variable, and then use the command line option -executionProfile to select the profile you want to use. Isn’t that what you’re trying to do?


#26

Drunda Nibel said:

Maybe I’m a little late in this discussion - or I missed or misunderstand something, then please excuse me. :slight_smile: But is there actually a certain reason why you don’t want to use the profile function built into Katalon Studio the way it is supposed to for the quite simple purpose of @Said A… and @Alex Jack to exchange a url when calling it via command line? You can simply create different profiles, each with a different url string variable, and then use the command line option -executionProfile to select the profile you want to use. Isn’t that what you’re trying to do?

I have explained the reason in my comment above at 9/28/2018 to this issue.

Please find the date of my initial post — 3/27/2018. At that time we had v 5.3.x which did not have Execution Profile yet. Still I wanted a method to specify parameters (username, password) runtime. Therefore I invented the method driven by katalon.properties. Later in April 2018, Execution Profile was introduced to Katalon Studio at v5.4.0.


#27

Yes, I had read that. But the discussion about difficulties in dealing with dependencies in order to get your undoubtedly great properties approach to work continued until October. And the second reason to be able to protect sensitive data from being published with the Git repository also applies to Katalon’s profile data, which can also be included in the .gitignore file, can’t it?

Despite all the merits your solution has earned, I just thought Said A. and Alex Jack might have missed the essence and power of this profile feature now available in Katalon Studio.


#28

There is another simple way to keep sensitive data out of the project directory. Just use

evaluate(new File(myLocalFilePath))

whenever a Groovy script file should be included whose code content should not be visible at this point.