Using base URL in profile

Hello,
I want to re-use my base URL inside execution profile.
Example:

I have GlobalVariable.MainUrl = ‘facebook.com

And inside the same execution profile I want to add new variable
GlobalVariable.Article1 = ‘GlobalVariable.MainUrl + /article1’

However it doesn’t work like that inside the profiles. What would be the correct syntax to do something like that?

Try this:

GlobalVariable.Article1 = "${GlobalVariable.MainUrl}/article1"

Note that

  • the variable must exist in the profile, having whatever value (can be an empty string), globals are not created ‘on-the-fly’
  • global variables are scoped to testsuites, so it is not shared across testcases unless you run them in a testsuite

Getting an error

Unable to navigate to '${GlobalVariable.MainUrl}/article1'

did you used double-quotes, as in my example, or single-quotes (which does not work) ?
it worked for me:

GlobalVariable.Article1 = "${GlobalVariable.MainUrl}/article1"
println(GlobalVariable.Article1)

output:

2022-07-28 17:47:33.346 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/globaltest
before test case
2022-07-28 17:47:33.722 DEBUG testcase.globaltest                      - 1: Article1 = $GlobalVariable.MainUrl/article1
2022-07-28 17:47:33.913 DEBUG testcase.globaltest                      - 2: println(Article1)
facebook.com/article1
2022-07-28 17:47:33.928 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/globaltest

2 Likes

But I want to assign this value inside execution profile.

So I have

<GlobalVariableEntity>
      <description></description>
      <initValue>‘facebook.com'</initValue>
      <name>MainUrl</name>
   </GlobalVariableEntity>

And second variable that uses the first one

<GlobalVariableEntity>
      <description></description>
      <initValue>‘${GlobalVariable.MainUrl}/article1'</initValue>
      <name>Article1</name>
   </GlobalVariableEntity>

Putting the Value of second one in double quotes throws me an invalid character error

why to do that?
it makes no sense, override the value of the new variable from the testcase script, this is why you have it
although you can simply use a local variable for this purpose, and you don’t need the global ‘Article’ one

1 Like

Okay I see what you mean.
So in the Profile I only keep MainUrl and inside test cases i change value for the articles url

exactly, whatever you need to compose from that mainurl you do it in the testcases code
that will keep your profile clean, and give you better control

1 Like