Error thrown when referencing global variables in test cases in Katalon Studio 5.4.1

I see that in the release notes for 5.4.1, there is a note that states:

  • Fix issues where Execution Profile/Global Variables does not work properly in Test Case Variables.

However, I am currently using Katalon Studio 5.4.1, and I still cannot use global variables in my test cases.

To reproduce the issue, if you create a new test case with the following script:

WebUI.openBrowser('')WebUI.navigateToUrl(GlobalVariable.testurl)WebUI.click(findTestObject('a_Make Appointment'))WebUI.closeBrowser()

with a global variable testurl defined as http://demoaut.katalon.com, the following message will be thrown:

Test Cases/test FAILED because (of) java.lang.NullPointerException: Cannot execute null+{testurl=http://demoaut.katalon.com}

Can I see your Global Variable definition?

Sure, here’s the definition.

image.png

So actually, going to File > Clean Up, and restarting Katalon Studio seems to fix the problem. What was strange is the global variables were working just fine, then I got this error message when I created a new test case (without modifying the global variables or the execution profile), but now it seems to be fine again. It happens from time-to-time, but I can’t reliably reproduce the issue, it’s just kind of quirky.

I have no problems here. Can you send me your project? By the way, that note in the release notes is referring to another issue, not related to your current one just FYI

I had the same problem as @JJ Loneman
and it didn’t work that File > Clean Up & restarting

Vinh Nguyen said:

I have no problems here. Can you send me your project? By the way, that note in the release notes is referring to another issue, not related to your current one just FYI

I could create another project, but you can also reproduce the issue by creating one of the sample projects File > New Sample Project > Sample Web UI Testing Project, creating a new profile, and adding a new global variable in that profile. Like I said though, it will work sometimes and randomly fail other times.

Since I can’t see more of the stacktrace in the error message, I’m guessing that whatever the global variable is being concatenated to in the Open Browser command is null where it should probably be an empty string

Facing similar issue

  1. Created a profile with variables username and password of string type.

  2. Created new test case to call a value using following line of code.

    WebUI.println GlobalVariable.username

Error message:

Test Cases/Playground FAILED because (of) java.lang.NullPointerException: Cannot execute null+{username=myuser, password=mypwd}

Some colleagues of mine are running into this as well. It seems like those of use that have upgraded Katalon are not having this while those that just installed to 5.4.2 are having it. We also noticed that when it works the default profile is the first in the list (both in the IDE and in the GlobalVariables.groovy). For those that the error occurs that profile is last in the list. Not sure why, but for some people default gets saved as the first and for some people it’s the last (resulting in error). @Vinh Nguyen can you use this info to try to recreate and fix the issue?

Hey everyone. This is only a partial answer, but this is what we found. We are using 5.4.2. We had created 2 new profiles and our tests stopped working (similar error to above) … oh oh … we then deleted the new profiles and re-ran the tests. Now “default” wasn’t working either.

After several minutes of running around the office with our arms in the air screaming in panic, we compared the current default.glbl to a backup I had made. We found a hidden (I think) field had been changed from true to false:

false

I closed Katalon, used notepad to change the false back to true, then reopened Katalon and the test started working again.

With impending deadlines, we haven’t tested further using multiple profiles, but this is something you might be able to work with.

Thanks for listening!

I’m facing the similar issue with v5.7.0

@John_Paul :
Can you tell us about the “hidden field” that you set back to false ? What’s its name ?

I’m having the same issue with Katalon 5.8 (project created on Windows, run in CLI mode on Linux).

@Aurelien_BREVERS There was an XML tag that go filtered out in the message. Sorry!

Anyway, what you were supposed to see is:

<defaultProfile>false</defaultProfile>

Changing the “false” back to “true” worked for us.

Sorry for the confusion!

1 Like

Further to this issue, we are now successfully using Profiles. This is what works for us:

  • Do not rename the default profile, or make another profile into the default
  • Put any Global Variables that do not change value based on the profile inside the default profile.
  • Create additional profiles to store GVs that will change based on the profile you select

Katalon will use the variables stored in default for all tests in addition to the variables in the profile you select.

1 Like

Thank you @John_Paul ! :slight_smile:

My root cause was that I deleted the default.glbl file (as it contained no global variable).

Restoring it (and checking it had the <defaultProfile>false</defaultProfile> tag) solved my problem.

Hi, I had the same problem. Version 5.10.1
I first renamed the files with a number and a minus. Like 01-test, 02-acc
Then I renamed the files again like
test
acc

And now I have no erros.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.