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

Problems to solve

Let me assume, I have a single Web Application in multiple environments: the development, the staging, the production-blue, the production-green and more. These environments have 99% same contents and features except the following differences:

Now I want to:

  1. I want to use Katalon Studio to test Web UI of all these environments using a single set of Test Suites/Test Cases.
  2. I want to store the Katalon project into the GitHub and to expose it public (just as I did here).
  3. Still I want to hide my sensitive information: hostname, username and password. I do not like making them visible anywhere in the repository.
  4. I want to run the test against multiple targets (hostnames) in Continuous Integration process on Jenkins. In order to do this, I need to be able to switch the test target by command line argument without modifying the source code of the test at all.

**

My solution published**

I believe I have developed a solution to the above problems. I have made a running demo on GitHub. Please have a look at this:
https://github.com/kazurayam/KatalonPropertiesDemo

Related discussions

In the Katalon Discussion Forum I found quite a few discussions on test reuse, passing parameters to automated tests, and hiding credentials.

I hope my study suggests something useful to those who may concern.

14 Likes

Upvote for this one. Thanks for your study and your implementations, we’ve been very grateful about this :slight_smile:

Regards

1 Like

However, this should be in ‘Tips and Tricks’ category, do you mind if I move it to that section?

Regards

Please do it.

1 Like

Vinh,

As I wrote in https://github.com/kazurayam/KatalonPropertiesDemo, I have a feature request to Katalon Studio Console Mode Execution so that it accepts argument which give value to JVM System Property.

Should I raise another post in ‘Feature/Improvement Suggestion’?

1 Like

kazurayam said:

Vinh,

As I wrote in GitHub - kazurayam/KatalonPropertiesDemo: katalon.properties file enhances usability of Katalon Studio, I have a feature request to Katalon Studio Console Mode Execution so that it accepts argument which give value to JVM System Property.

Should I raise another post in ‘Feature/Improvement Suggestion’?

Yes this should be raised in ‘Features/Improvement Suggestion’ category instead.

Vinh,

I added this:

1 Like

What an amazing field study. Kudos to Kaz.

Hi All,

what would be the advantage of using the configurable properties instead of simply using different profiles. The only advantage i see is that you can use the same profile (global variables) with multiple properties. Is there more than that?

Thanks and best regards,
Said

Said,

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.

The advantage of katalon.properties file for me, in comparison to Profiles, is that I can exclude the file out of Git repository. By .gitignoring the katalon.properties I can be 100% sure that my sensitive information(password) is NOT exposed to public even when I put the repository public on GitHub.

1 Like

Thanks @kazurayam for the explaination. This sounds plausible.

I am using profiles and by now I am quite happy. However would love to have a possibility to overwrite global properties in the execution command. e.g. i want to run the test with almost the same profile, only the baseURL in the profile is different. For that i want to specify the baseURL in the execution command. e.g.

>.\katalon.exe -DbaseURL=http://www.example1.com -runMode=console ...

Do you know if there is a smart way for doing that? May I use your functionality for that?

Thanks!
Said

-DbaseURL=http://www.example1.com

No, specifying Java System Property by -D option on the command line is not supported.

1 Like

Using OS-level environment variable would be an option for you.

In the command line or windows bat script you would do:

>set baseURL=http://www.example1.com>...>.\katalon -runMode=console ...

and in TestListener or Test Case you do

if (System.getenv("baseURL") != null) {    GlobalVariable.baseURL = System.getenv("baseURL")}
3 Likes

That looks like a good option. I will try it out and check if that would solve my problem smart and easy.

Thanks for your help! Much appreciated :slight_smile:

kazurayam said:

Using OS-level environment variable would be an option for you.

In the command line or windows bat script you would do:

>set baseURL=http://www.example1.com>...>.\katalon -runMode=console ...

and in TestListener or Test Case you do

if (System.getenv("baseURL") != null) {    GlobalVariable.baseURL = System.getenv("baseURL")}

I have tried to make something like that for hit the result to test railt but it doesn’t work

this my code on Testlistener/hook’s

if (System.getenv("runMode") == "console") {			
GlobalVariable.UpdateTestRail = System.getenv("updateTestRail")
GlobalVariable.TestRailRunId = System.getenv("testRailRunID")	
}
./Katalon\ Studio.app/Contents/MacOS/katalon --args -noSplash  -runMode=console -updateTestRail=true -testRailRunID=5193 -consoleLog -projectPath="/Users/automation-web/Automation-Web.prj" -retry=0 -testSuiteCollectionPath="Test Suites/TestSuiteCollection/Run Smoke Test 1(Chrome)"

I have tried also as you explain, by typing and set parameters but not working

>set updateTestRail=true>set testRailRunID=5193>./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)"

but it doesn’t work

Any messages in the log?

Did you defined _UpdateTestRail and _TestRailRunId in the defaul Profile before running the script?

You need to defind variables in the defaul Profile.PNG

1 Like

yes I have:

It’s looks like I missed something, did I need to use jar file which is you provided and create katalon properties?

if I uses katalon properties it means I still need to open file and edit the properties before execute the command right? is there any way to make it put the variable like usually uses for executing katalon via command line, by typing -updateTestRail=true -testRailRunId=5191

Screen Shot 2018-10-09 at 13.06.09.png

Yes, you need to import MultiSourcedProperties-1.0.jar file into Katalon Studio in order to load the contents of katalon.properties file.

You can download the jar from

  1. https://github.com/kazurayam/MultiSourcedProperties/releases
1 Like

is there any way to make it put the variable like usually uses for executing katalon via command line, by typing -updateTestRail=true -testRailRunId=5191

No, there isn’t. It is the very reason why you are now working on using OS-level environment variable, isn’t it? Using environment variables, you are going to overwrite the values of GlobalVariables.

1 Like

I have installed your jar.

And for properties I just need to uses properties which is generated from Build CMD > Generate Property File and replaces it with my variable, right?

this is my content of console.properties

this my code on Testlistener/hook’s

if (System.getenv("runMode") == "console") {			
GlobalVariable.UpdateTestRail = System.getenv("updateTestRail")
GlobalVariable.TestRailRunId = System.getenv("testRailRunID")	
}

I tried to uses my properties but it’s gives result like this:


Then I did,

$cd /Applications/$set updateTestRail=true$set testRailRunID=5193$./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)"

but still my test rail not updated

Screen Shot 2018-10-09 at 14.21.49.png

Screen Shot 2018-10-09 at 15.02.21.png