Hi Community,
Just wanted to understand if it is possible to have a dynamic Global Variable in Profile.
I need to use a Global Variable for CurrentDateTimeStamp in multiple places in my script.
Date and Time will keep changing with every passing day.
So is it feasible to have some logic in Global Variable, so that without touching the Global Variable it will get updated by itself before running any scripts?
There is no such magic. If a Global Variable is updated without any explicit instruction, we would rather call it a bug.
But you can write a statement that updates the GlobalVariable in a Test Listener rather than in the Test Case scripts.
In a Test Listener, you want to write a single line of code that updates the Global Variable as CurrentDateTimeStamp. Then the updated value will be observable for every Test Case scripts.
Thank you @kazurayam.
I have never used listeners before but on reading the documentation, it looks interesting.
For a start can you please help me with the above date timestamp code?
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
WebUI.comment("TC1: ${GlobalVariable.CurrentDateTimeStamp}")
TC2:
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable
WebUI.comment("TC2: ${GlobalVariable.CurrentDateTimeStamp}")
You want to create a Test Suite TS1 which comprises with TC1 and TC2.
Thank you so much @kazurayam.
I was just wondering if we can do it at Test case level also.
Your current script ran and gave the same Timestamp for both the scripts because it was enabled at Test Suite level I guess.
The actual Timestamp when running the second Test Case might be different.
Will the Timestamp automatically update if we do it at testcase level?
Like TC1 Time stamp 14:01
TC2 Timestamp 14:05
Also, if there is any possibility to get A.M/P.M format based on the actual Time?