So I have a testcase where I write data to an excel file using a custom keyword, this works fine the file is updated. However, in the next testcase I need to retrieve this data again to verify. My issue is that in this test case I am binding the data file to variables but the data being used is the data before the excel file was updated. Which makes me believe that Katalon does not refresh the data from the excel file that is being used during execution. My question is is there a way for me to refresh the data file? Or is my only solution to create another custom keyword to retrieve the data directly from the excel file?
I think you need to call your excel file again. Because by default katalon only reads the loaded test data upon execution and it will be the same data even if you did a change on your test data while executing the test. It’s like you need to restart the test to acquire the updated values.
Now, to get the updated values you need to access the excel directly or programmatically.
try calling it using this. . . I think this will do the trick…
import com.kms.katalon.core.testdata.reader.ExcelFactory
//create an instance
Object excel = ExcelFactory.getExcelDataWithDefaultSheet("yourExcelPath.xlsx", "SheetName", true)
//pass your test case variables
excel.getValue("tc_variable", 1)
/**
Where 1st param is string column name and 2nd param integer is row number.
theres an overload to that method where the first param is integer.
**/
Or if you don’t have many sheets or you only have default sheet in your test data, try this other approach. . .
import com.kms.katalon.core.testdata.ExcelData
ExcelData excelData = new ExcelData("yourExcelPath.xlsx", true)
excelData.getValue("tc_variable", 0)
//same param definition as mentioned above.
import com.kms.katalon.core.testdata.reader.ExcelFactory
//create an instance
ExcelData excel = ExcelFactory.getExcelDataWithDefaultSheet("yourExcelPath.xlsx", "SheetName", true)
//pass your test case variables
excel.getValue("tc_variable", 1)
Where
-First parameter will be the excel path
-Second parameter will be the sheet name. You can change sheet name on run time just put a string variable
-Third, make it true if you want to make the first row as headers or false if you want to make the first row as plain record