I cant assign the cookie value during runtime in global variable the get cookie value =Null any help ?(updating the globvar during runtime)

In the test case, I assigned the cookie var to global
request header contain the value
GlobalVariable.CloudCookies = CookiesActions.getCookieValue()

APIActions.verifyStatusCode(GlobalVariable.StatusCode[‘Created’], GlobalVariable.WishlistAPIs.get(1))

The getcookie method
public static void getCookieValue() {
WebUI.waitForPageLoad(5, FailureHandling.STOP_ON_FAILURE)
WebDriver driver = DriverFactory.getWebDriver()
// create a temp variable to store the cookies
String cookieString = ‘’
// get all the cookies
Set cookieCollection = driver.manage().getCookies()
// a list of the cookies we want to use in our API calls later (these will get copied) ** must match EXACTLY
def interestingCookies = [
// loop through each cookie and append COOKIENAME=COOKIEVALUE; to the temp variable
for (Cookie currentCookie : cookieCollection) {
if (interestingCookies.contains(currentCookie.getName())) {
cookieString += (((currentCookie.getName() + ‘=’) + currentCookie.getValue()) + '; ')
// print the cookies for debugging
// set the cookies to our global variable. This is the most important bit!




Let me investigate more and back to you soon.

1 Like

Hello, @Elly_Tran Any Updates regarding this issue ?


Hello Any Updates regarding this issue


Have you been successful until this step?

// print the cookies for debugging

Please double check if you have generated the cookie string correctly.

the cookie value is printed perfectly in the console but it’s not updated in the default file

Your test script can update GlobalVariables in memroy. But the Execution Profile files (e.g, “default”)
will be left unchanged. Katalon Studio does not provide any built-in way to update the Executio Profile files programatically.

If you want to, you need to develop some Groovy script that read and write the XML files for yourself.

But I guess, you would not really need to do so.

1 Like

I assign the value for the Globalvar like this GlobalVariable.cookie=the string val

Do you have any possible solution?

No, I don’t,

I have never found it neccesary for me.

I wonder why you want to update the file.

If you want to write a Groovy script to update a XML file, then the following article may help.

katalon is not postman.
such have been allready explained in various topics.
katalon never writes back on the fly data for UI for GlobalVariables class

Check if the cookie exists
if (document.cookie.indexOf(“yourCookieName=”) !== -1) {
// Retrieve the cookie value
var cookieValue = document.cookie
.split(“; “)
.find(row => row.startsWith(“yourCookieName=”))

// Assign the cookie value to a global variable
window.globalVariable = cookieValue;
In this example, we check if the cookie exists, retrieve its value, and then assign it to a global variable named `globalVariable". Click here for detail.