Hi everyone, I’m trying to follow best practices by not hardcoding my website URL. I went into Profiles, created a Global Variable called G_SiteURL, and set the value to https://my-testing-app.com.
But when I run my script, the browser opens up, stays on a blank white page for a few seconds, and then the test fails. It’s like Katalon isn’t even reading the variable. I tried calling it in my script like this:
Groovy
// My script line
WebUI.openBrowser(GlobalVariable.G_SiteURL)
In the Log Viewer, it says: PASSED - Open browser with url: ''
Wait, why is the URL empty? I definitely typed it into the Profile! I even tried restarting Katalon, but it still opens a blank page. Am I missing a step to “connect” the profile to the test?
That’s good to see. It is however very much not working for me. I’m working in projects that have been around since Katalon v7, and are now being upgraded to v11. We’re holding off on upgrading to v11 because this issue is pervasive across all projects in the enterprise. This is replicated by every member of my team.
What you are experiencing is an Execution Profile Mismatch. This is one of the most common hurdles for beginners. In Katalon Studio, defining a variable in a Profile is only half the battle; you must explicitly tell Katalon which Profile to use during the execution. By default, Katalon uses the “default” profile. If your variable is in a profile named “Staging” or “Production,” but the “default” profile is empty, the variable returns a null or empty string.
The Solution: Selecting the Active Profile
You don’t need to change your code; you need to change your Execution Context.
Check the Execution Selector: Look at the top toolbar in Katalon Studio, next to the “Run” (Play) button. There is a dropdown menu that usually says default.
Switch Profile: Click that dropdown and select the specific Profile where you defined G_SiteURL.
Verify Variable Typing: Ensure the variable “Type” in your Profile is set to String and not something else.
Custom Keyword: The “URL Guard”
To prevent your tests from failing with confusing “blank page” errors, you can create a Custom Keyword that validates the Global Variable before the browser even opens. This is a “Fail-Fast” architectural strategy.
Groovy
package com.config.utils
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.util.KeywordUtil
import internal.GlobalVariable
public class ConfigValidator {
/**
* Checks if the Global URL is valid before starting the test
*/
@Keyword
def verifyGlobalUrl() {
String url = GlobalVariable.G_SiteURL
if (url == null || url.isEmpty() || url.trim() == "") {
KeywordUtil.markFailedAndStop("ERROR: GlobalVariable.G_SiteURL is empty! Check if you selected the correct Execution Profile.")
} else {
println "Proceeding with environment URL: " + url
}
}
}
Strategic Advice:
The Default Profile Strategy: A common expert tip is to put your “Local” or “Dev” environment settings in the default profile. This way, if you forget to switch profiles, the test still runs against a safe environment.
Check the ‘Internal’ folder: In the Script view, ensure your import says import internal.GlobalVariable as GlobalVariable. If this import is missing or corrupted, Katalon won’t recognize the variable.
Console Log Check: Always look at the very first few lines of the Console tab. It will say Variable 'G_SiteURL' is set to .... If it says null, the Profile hasn’t loaded.
Did you create a new Profile for your URL, or did you add the variable to the existing “default” profile?
I opened a Katalon Studio project; I had the Exection Profile default already; I added a new Excecution Profile stg;
While I DON’T mark the stg as default, I looked at the file in the project directory: Libs/internal/GlobalVariable.groovy.
package internal
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.main.TestCaseMain
/**
* This class is generated automatically by Katalon Studio and should not be modified or deleted.
*/
public class GlobalVariable {
/**
* <p></p>
*/
public static Object wait
static {
try {
def selectedVariables = TestCaseMain.getGlobalVariables('default')
selectedVariables += TestCaseMain.getGlobalVariables(RunConfiguration.getExecutionProfile())
wait = selectedVariables['wait']
} catch (Exception e) {
TestCaseMain.logGlobalVariableError(e)
}
}
}
And I looked into the Libs/internal/GlobalVariable.groovy file again. It was changed to:
package internal
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.main.TestCaseMain
/**
* This class is generated automatically by Katalon Studio and should not be modified or deleted.
*/
public class GlobalVariable {
/**
* <p></p>
*/
public static Object wait
static {
try {
def selectedVariables = TestCaseMain.getGlobalVariables('stg')
selectedVariables += TestCaseMain.getGlobalVariables(RunConfiguration.getExecutionProfile())
wait = selectedVariables['wait']
} catch (Exception e) {
TestCaseMain.logGlobalVariableError(e)
}
}
}
The empty URL in the log confirms your profile isn’t loading at runtime. If you created the variable in a custom profile (not “default”), you have to explicitly select it. The default profile auto-loads; custom ones do not.
Right-click your test suite, go to Execution Settings, and select your profile from the dropdown. If running a standalone test case, go to Run > Execution Settings and pick the profile there.
Quick sanity check: add println GlobalVariable.G_SiteURL before the openBrowser call. If it prints null, the profile is definitely not active.