Hi Guys,
Just wanted to share some ideas about test data. If your test data changes upon running your test automation it seems impossible to load it again or refresh it when you use the standard process of loading your test data file.
To give you a scenario, assuming that you already loaded your test data(.csv, .xlsx) in the data files or you have already bind it in your test suite. When you execute your suite the automation will load the test data first before running your test steps or code. So it means if your test steps or code has the ability to change the test data like running a third party application(.vbs, .exe) that penetrates the .csv or .xlsx file, the currently loaded test data will be useless, you need to load it again to use the updated values of your test data. So this is like having a dynamic test data.
In order to load it programmatically, you need to have a look at the following classes
(CSVData, ExcelData, DBData, InternalData, TestData, etc. . . .) you can find those classes in this link: Index (Katalon Studio API Specification)
In my case, Iām using CSVData as my dynamic test data file. CSVData class allows you to programmatically load your .csv file and set your desired configurations. There are 3 parameters in that class CSVData(String sourceUrl, boolean containsHeader, CSVSeparator separator).
To give an example of how to use it refer to my shortcode below:
import com.kms.katalon.core.testdata.CSVData
CSVData csvData = new CSVData(āC:\yourCSV.csvā, true, CSVSeparator.COMMA)
//to access or to get the .csv file values refer to some commonly used commands
csvData.allData or csvData.getAllData()
csvData.getValue(ācolumnnameā, int rowNumber)
csvData.rowNumbers //this is to get all the used rows or total number of rows
csvData.columnNumbers
csvData.columnNames
. . . and many more.
Hope this helps