Is there any property/method that I can use to retrieved the current running Test Data Test Data file ID / Data Source File ? I know the getSourceURL() method, but that required me to first know the Test Data ID. Is there any method I can get the Test Data ID from runtime?
Any idea, anyone?
@MaKatalon Did you figure out how to do this? I need to get the Data File name and location/url in code so I can write to it. I will be changing the Data File, so first I load File1 and complete running through all rows. Next I will run the same test for another client using File2. When I am writing to the data file, I need to know the name of the file. The location of the file will be the same, but the files will have different names. As shown below, before each run, I will substitute this file with another one. So I need to get this location, so I can write to the appropriate file.
Hi, not really have a way to get the runtime data Id. However, I implemented workaround for this by storing the data ID as a variable,and reference the file via the ID. I think this is also applicable for your problem,since you are changing the data file, you shld already know the Test Data ID upfront. You may store this ID as variable and change the ID whenever you switching files. Hope it helps.
@MaKatalon Thanks for the response.
I notice that the dat file, that is saved in DataFiles folder has a property dataSourceUrl, which has the filename location. I am trying to see how to access that info so we can use it in the code.
If anyone knows how to do it, please let me know. TIA.
To access dataSourceUrl in script mode, you can refer to our javadoc: https://docs.katalon.com/javadoc/com/kms/katalon/core/testdata/TestData.html
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData import com.kms.katalon.core.testdata.TestData as TestData TestData data = findTestData('test data id') println data.getSourceUrl()