# URL Variables & Testing Production vs. Staging

**URL:** <https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [September 15, 2021, 5:59pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326 "2021-09-15T17:59:18Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam.olexo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/adam.olexo/32/16104_2.png) [@adam.olexo](https://forum.katalon.com/u/adam.olexo)\
**Post date:** [September 15, 2021, 5:59pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/1 "2021-09-15T17:59:18Z")

</div>

I’m developing a project centered around testing our production environment “software as a service” web application. I’d like to take as much of my existing scripting and be able to test our staging environment as well, which exists in a different URL of course. What I want to know is if there is a way to define variables or something along those lines that will have test cases choose to be executed in our production URL or staging URL. Would it be easier to create a new project, copy and paste my existing scripts, and simply change the initial navigateToUrl commands? Obviously not every single script element may execute exactly the same way between the two environments but I would test my tests and make any necessary changes to objects, etc.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [September 15, 2021, 8:32pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/2 "2021-09-15T20:32:02Z")

</div>

Use different profiles, one for each environment.

In the production profile, set TARGET\_URL to the url for production.

In the staging profile, set TARGET\_URL to the url for staging.

Then…

```auto
WebUI.navigateToUrl(GlobalVariable.TARGET_URL)

```

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [September 15, 2021, 9:45pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/3 "2021-09-15T21:45:47Z")

</div>

If you use Profiles like @Russ_Thomas suggests, you have to remember to choose the correct environment after you launch KS and before starting your testing. Remember the computer does not change the environment profile setting by itself; the profile stays throughout your testing but you have to reset it when you start or restart KS.

![image](https://europe1.discourse-cdn.com/katalon/original/3X/6/3/63baabe98d64fab9228ad56b0e55a9462cd8d14a.png)

---

<div class="post-metadata">

**Author:** ![adam.olexo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/adam.olexo/32/16104_2.png) [@adam.olexo](https://forum.katalon.com/u/adam.olexo)\
**Post date:** [September 16, 2021, 2:02pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/4 "2021-09-16T14:02:09Z")

</div>

@grylion54 @Russ_Thomas  
This is a solid solution, thank you both. Forgive me for my ignorance as I want to learn everything I can, but if I edit `navigateToUrl` commands in one profile, will that inadvertently affect the other profile’s scripts?

In other words, will I need to go through and edit scripts each time?

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [September 16, 2021, 2:06pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/5 "2021-09-16T14:06:20Z")

</div>

> [@adam.olexo](#):
>
> In other words, will I need to go through and edit scripts each time?

No, that was the point. You set the actual URL value in a profile. You don’t touch the script. When you execute the suite (or test case) you decide which profile is selected first.

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/0/d/0d4423cc7a0a014864f8a5fadebc5e899d9d6d3e.png)

---

<div class="post-metadata">

**Author:** ![adam.olexo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/adam.olexo/32/16104_2.png) [@adam.olexo](https://forum.katalon.com/u/adam.olexo)\
**Post date:** [September 16, 2021, 2:13pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/6 "2021-09-16T14:13:12Z")

</div>

@Russ_Thomas Thank you very kindly. I see the wisdom here. On a more personal note, do you find pretty smooth translation in your staging tests vs. production tests? I suppose I foresee some minor issues where something is a bit different in a staging environment.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [September 16, 2021, 2:21pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/7 "2021-09-16T14:21:21Z")

</div>

> [@adam.olexo](#):
>
> do you find pretty smooth translation in your staging tests vs. production tests?

I (we) don’t test like that.

I run suites continuously against two development systems (one for SQL Server back end and the other for Oracle). When a dev branch is about to be finalized, it is given a “tag” and tested for approximately one week before the branch is closed (and the software released). Then I revert back to testing the dev branch again.

---

<div class="post-metadata">

**Author:** ![adam.olexo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/adam.olexo/32/16104_2.png) [@adam.olexo](https://forum.katalon.com/u/adam.olexo)\
**Post date:** [September 17, 2021, 5:19pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/8 "2021-09-17T17:19:01Z")

</div>

@Russ_Thomas Thanks for your help again.  
Things were going smoothly but I’ve noticed now that I’m receiving  
Caused by: java.lang.IllegalArgumentException: Url cannot be null or empty  
when calling `navigateToUrl` and passing the global variable to the command. This is in both profiles.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [September 17, 2021, 5:53pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/9 "2021-09-17T17:53:26Z")

</div>

Show me the code, the Profile definition and the error.

---

<div class="post-metadata">

**Author:** ![adam.olexo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/adam.olexo/32/16104_2.png) [@adam.olexo](https://forum.katalon.com/u/adam.olexo)\
**Post date:** [September 17, 2021, 6:31pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/10 "2021-09-17T18:31:41Z")

</div>

@Russ_Thomas  
WebUI.navigateToUrl(GlobalVariable.TARGET\_URL)  
 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/1/d/1deb6366669ffd358be623460d58140aaaf3be9e.png)  
`=============== ROOT CAUSE =====================  
Caused by: java.lang.IllegalArgumentException: Url cannot be null or empty

================================================

09-17-2021 01:37:19 PM Test Cases/Alerts Tests/9000 - Alerts - Alerts Log

Elapsed time: 2.729s

Test Cases/Alerts Tests/9000 - Alerts - Alerts Log FAILED.  
Reason:  
com.kms.katalon.core.exception.StepFailedException: Unable to navigate to ‘null’  
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)  
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)  
at com.kms.katalon.core.webui.keyword.builtin.NavigateToUrlKeyword.navigateToUrl(NavigateToUrlKeyword.groovy:83)  
at com.kms.katalon.core.webui.keyword.builtin.NavigateToUrlKeyword.execute(NavigateToUrlKeyword.groovy:67)  
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)  
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.navigateToUrl(WebUiBuiltInKeywords.groovy:187)  
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$navigateToUrl$0.call(Unknown Source)  
at 9000 - Alerts - Alerts Log.run(9000 - Alerts - Alerts Log:38)  
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)  
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)  
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:430)  
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:421)  
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:400)  
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:392)  
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:273)  
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)  
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)  
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)  
at TempTestCase1631900237221.run(TempTestCase1631900237221.groovy:25)  
Caused by: java.lang.IllegalArgumentException: Url cannot be null or empty  
at com.kms.katalon.core.webui.keyword.builtin.NavigateToUrlKeyword$\_navigateToUrl\_closure1.doCall(NavigateToUrlKeyword.groovy:75)  
at com.kms.katalon.core.webui.keyword.builtin.NavigateToUrlKeyword$\_navigateToUrl\_closure1.call(NavigateToUrlKeyword.groovy)  
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)  
… 17 more  
`

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [September 18, 2021, 1:25am UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/11 "2021-09-18T01:25:52Z")

</div>

@adam.olexo

In which Execution Profile did you define `GlobalVariable.TARGET_URL` ?  
In the “default” profile? or else?

Whichever the Execution Profile is, are you sure you applied that profile when you ran your test case?

I guess, you created an Execution Profile (e.g, “foo” profile) where you defined the `GlobalVariable.TARGET_URL`, but you forgot to apply the “foo” profile for the test case run.

 ![foo](https://europe1.discourse-cdn.com/katalon/original/3X/d/c/dc7b450dec79a5aac8e3047057e77a9d65de4e87.png)  
In that case, your test case will fail to find the GlobalVariable.TARGET\_URL, as it is not there in the applied Profile.

---

<div class="post-metadata">

**Author:** ![adam.olexo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/adam.olexo/32/16104_2.png) [@adam.olexo](https://forum.katalon.com/u/adam.olexo)\
**Post date:** [September 20, 2021, 1:29pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/12 "2021-09-20T13:29:19Z")

</div>

@kazurayam I’ve defined an additional profile called “Staging” to go along with production which is, of course, “default”. Both profiles have global variables established with TARGET\_URL being the string value of each respective URL to navigate to the desired environment. Neither selecting “Staging” nor “default” changes the error output.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [September 20, 2021, 2:08pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/13 "2021-09-20T14:08:30Z")

</div>

Put this at the top of a test and run it against each profile:

```auto
println GlobalVariable.TARGET_URL + " *************************"

```

Then check the console.

---

<div class="post-metadata">

**Author:** ![hritik](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/hritik/32/23869_2.png) [@hritik](https://forum.katalon.com/u/hritik)\
**Post date:** [January 23, 2025, 7:11am UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/14 "2025-01-23T07:11:42Z")

</div>

I have some urls which are different for different testing environments and some more variables which are common.  
What’s the best way to keep the urls for different testing environment and some more variables which are common?  
Also, I have made profiles based on the different application to segregate the variables related to the application. so i cant make profiles for different env of different application.

Pls give an idea and thanks in adv!!

---

<div class="post-metadata">

**Author:** ![Monty\_Bagati](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/monty_bagati/32/33047_2.png) [@Monty\_Bagati](https://forum.katalon.com/u/Monty_Bagati)\
**Post date:** [January 23, 2025, 7:24am UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/15 "2025-01-23T07:24:33Z")

</div>

Please create Global Variables here (used default profile , u can create more like QA , Prod etc. and create variables there)

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/3/b/3b5a8e1b90992c026746cf217d5bb89b623c19d1.png)

and call the in any test case like here

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/b/d/bd6d48f539735da12ec97d653a24570dc6595b31.png)

and use it for different env. like QA staging here

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/f/c/fcf95dddede961bd3feb0855aeb0b99e80c09f9e.png)

and run in test suite collection like this

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/c/b/cbdcd50511913871e33fda5f7aa70d1424b3779d.png)

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [January 23, 2025, 5:19pm UTC](https://forum.katalon.com/t/url-variables-testing-production-vs-staging/58326/16 "2025-01-23T17:19:37Z")

</div>

The way KS handles Profiles has changed from the earlier posts of 2021. Here is an update to their use of Profiles:

> [@Failed to implement case compatibility with multiple environments by using profiles](http://forum.katalon.com/t/failed-to-implement-case-compatibility-with-multiple-environments-by-using-profiles/153355/4):
>
> If you have a variable that is used in all environments, then put that variable in the “default” profile. If the variable does not change in any other environment, then that is the only placement you need. As an example, since I am the Tester, I have my user id, “gTestId”, only in the “default” profile and I don’t need to overwrite it in any other profile. Edit: All variables that will be initialized with only an empty value, or 0, are only in the “default” profile. Those variables that need …

As @Monty_Bagati says, use the “default” profile for most of your values and then copy those that are different in each of the other profiles.
