Getting 'Data Files/ListOfAccounts.xlsx' does not exist when trying to use 'TestDataFactory.findTestData'

Katalon Studio Version:
KSE 8.6.6, Build 208
Windows 11 Enterprise (64-bit)
Chrome Version: 117.0.5938.132 (Official Build) (32-bit)

Hi folks, I am getting Data Files/ListOfAccounts.xlsx does not exist when trying to use TestDataFactory.findTestData. I’ve not been able to figure out the issue to-date, does anyone have any suggestions/insight as to how I can fix this issue? I am using the following:

The ListOfAccounts.xlsx file is stored here: C:\Users\qatester\Katalon_QAS_Projects\12-irwworkstation\Data Files\ListOfAccounts.xlsx

import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import com.kms.katalon.core.testdata.TestDataFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

def smartData = TestDataFactory.findTestData('Data Files/ListOfAccounts.xlsx')
for (row = 1; row <= smartData.getRowNumbers(); row++) {
		WebUI.comment('row count is ${smartData.getRowNumbers()')
}

Also tried… Which resulted in the same error.

import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import com.kms.katalon.core.testdata.TestDataFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

def smartData = TestDataFactory.findTestData('ListOfAccounts.xlsx')
for (row = 1; row <= smartData.getRowNumbers(); row++) {
		WebUI.comment('row count is ${smartData.getRowNumbers()')
}
=============== ROOT CAUSE =====================
For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshooting.html
================================================
10-03-2023 09:21:39 AM Test Cases/21 RTMUpgrade/GetDataFromExcelFile
Elapsed time: 0.593s
Test Cases/21 RTMUpgrade/GetDataFromExcelFile FAILED.
Reason:
java.lang.IllegalArgumentException: Cannot find test data with id 'Data Files/ListOfAccounts.xlsx' because (of) 'java.lang.IllegalArgumentException: Test data with id 'Data Files/ListOfAccounts.xlsx' does not exist'
	at com.kms.katalon.core.testdata.TestDataFactory.findTestData(TestDataFactory.java:132)
	at com.kms.katalon.core.testdata.TestDataFactory$findTestData.call(Unknown Source)
	at GetDataFromExcelFile.run(GetDataFromExcelFile:21)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:448)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:144)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:135)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1696350096178.run(TempTestCase1696350096178.groovy:25)
2 Likes

Can you do a test run in which you remove the file’s extension? In my home setup, I have several tests of OP questions in which the setup is without the extension.

def smartData = TestDataFactory.findTestData('Data Files/ListOfAccounts')

Thanks Mike,
I did not think to remove the extension but I am still seeing the same error.

def smartData = TestDataFactory.findTestData('Data Files/ListOfAccounts')
for (row = 1; row <= smartData.getRowNumbers(); row++) {
		WebUI.comment('row count is ${smartData.getRowNumbers()')
}
=============== ROOT CAUSE =====================
For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshooting.html
================================================
10-03-2023 02:21:55 PM smartData = findTestData("Data Files/ListOfAccounts")
Elapsed time: 0.045s
Test Cases/21 RTMUpgrade/TC00 GetDataFromExcelFile FAILED.
Reason:
java.lang.IllegalArgumentException: Cannot find test data with id 'Data Files/ListOfAccounts' because (of) 'java.lang.IllegalArgumentException: Test data with id 'Data Files/ListOfAccounts' does not exist'
	at com.kms.katalon.core.testdata.TestDataFactory.findTestData(TestDataFactory.java:132)
	at com.kms.katalon.core.testdata.TestDataFactory$findTestData.call(Unknown Source)
	at TC00 GetDataFromExcelFile.run(TC00 GetDataFromExcelFile:5)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:448)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:144)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:135)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1696368111091.run(TempTestCase1696368111091.groovy:25)

Okay, how about the Data File routine from the following KS doc?

With the spreadsheet for the OP questions, I do have a “.dat” file that is a XLS to the location of the associated spreadsheet.

1 Like

Thanks will check the document :slight_smile:

Hello @Dave_Evers : copy the below code and it should work now. My KS version is 8.6.8. Katalon expects the file without an extension. I tried your code as well and yes it was throwing “File doesn’t exist error” and hence modified the code a little bit

import com.kms.katalon.core.testdata.TestDataFactory
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

def smartData = TestDataFactory.findTestData(‘Data Files/ListOfAccounts’)
def rowCount = smartData.getRowNumbers()
WebUI.comment(“row count is ${rowCount}”)
for (row = 1; row <=rowCount ; row++) {

}

Note : This solution is only wrt to your code in question only.

1 Like

Hi @Dave_Evers
Please check your Data Files Folder
selected excel file mapping may be removed

This is a bad idea.

You should not locate your Excel file in the Data Files folder. That makes yourself confused. You should locate your Excel files somewhere else.


Let me show you my running example project

I have a Excel file <projectDir>/data.xlsx. Please note that the Excel file is NOT located inside the Data Files folder.

I made an entity named d1 in the Data Files in the Tests Explorer. The d1 points me to the Excel file <projecitDir>/data.xlsx.

The test case script refers to d1, not to the Excel file:

import static com.kms.katalon.core.testdata.TestDataFactory.findTestData

def d1 = findTestData('Data Files/d1')

List<List<String>> rows = d1.getAllData()
rows.forEach { row ->
	if (row[0] != '') {
		println row.toString()
	}
}

The entity "Data Files/d1" enables me to move the Excel file to anywhere without changing the test case code. Even I can change "Data Files/d1" to refer to CSV or SQL database without chainging the test case source. One layer of indirect reference to file makes me free.

2 Likes

Thanks @kazurayam, this works perfectly!
Thanks to all that took the time to help out!