Is it possible to iterate through the internal data file row in a test script?
https://docs.katalon.com/katalon-studio/docs/shopping-cart-prj.html#data-files gives the following sample code:
TestData product = findTestData(GlobalVariable.dataFile)
List<String> productList =
product.getAllData().stream()
.map{data -> data[0]} /* get first column of each row in data file */
.collect(Collectors.toList()) /* add collect and parse to list*/
Would you know what needs to be changed in this code if I want to get first row in a data file instead of column?
https://docs.katalon.com/javadoc/com/kms/katalon/core/testdata/TestData.html#getAllData()
Returns:
a List that contains all data of each rows, which each item is a List of raw data from each cell in that row
If you are not familiar with the “Stream API” of java, you can use usual “for” loop.
for (int xRow = 0; xRow < product.size(); xRow++) {
List<String> row = product.get(xRow)
for (int xCol = 0; xCol < row.size(); xCol++) {
String value = row.get(xCol)
println "(${xRow},${xCol}) ${value}"
}
}