CMD execution with a data xlsx file in project - file not found

We have a data file (xlsx) ins our katalon project. We’re trying to run the project with CMD. We are getting an error when trying to use the data file: FileNotFound: Data Files/sample_text_2.xlsx

Do I need to add this data file path as an option under the CMD. Here is my CMD :
katalon -noSplash -runMode=console -consoleLog -noExit -projectPath=“C:\Users\Administrator\Desktop\my_project\CC_UI_Basic.prj” -retry=0 -testSuitePath=“Test Suites/prod_test” -executionProfile=“default” -browserType=“Chrome”

TC_003_data_input FAILED because (of) (Stack trace: Data Files/Sample_text_2.xlsx

Any suggestions?

I suppose that your test case code declares the Excel file with a path relative to the ‘current directory’ like (in Script mode):

File x = new File('.\Data Files\Sample_text_2.xlsx')

This would work if you run the test script through GUI. But it would fail if you run it in Console Mode. The point is: where the current directory ( .\ ) is pointing to?

When run through GUI, the current directory is set equal to the project directory. But in Console mode, you are asked to cd to the Katalon-installed directory. When the Katalon-installed directory is current, then .\Data Files\Sample_text_2.txt file not be found.

In your test case, you should somehow resolve the absolute path. Try the following:

import com.kms.katalon.core.configuration.RunConfigurationFile x = new File(RunConfiguration.getProjectDir() + '\Data Files\Sample_text_2.xlsx')
1 Like

Very good information. Thanks for point me to the correct spot. Here is my code for my file:

Object excelData = ExcelFactory.getExcelDataWithDefaultSheet("Data Files/Sample_text_2.xlsx", 'Sheet1' , true)
for(int row = 1; row <= excelData.getRowNumbers(); row++)
WebUI.sendKeys(findTestObject('Object Repository/Content_App/i_text_input_box'), Keys.chord(Keys.ENTER))
WebUI.sendKeys(findTestObject('Object Repository/Content_App/i_text_input_box'), Keys.chord(Keys.COMMAND, 'a'))
WebUI.clearText(findTestObject('Object Repository/Content_App/i_text_input_box'))
WebUI.setText(findTestObject('Object Repository/Content_App/i_text_input_box'), excelData.getValue("input_text_sample", row))
CustomKeywords.'com.clickhelper.clickHelper.clickUsingJS'(findTestObject('Object Repository/Content_main_func/a_summarize'), 


Have you changed your code? Is your problem resolved?

Not yet, I’m try to see how I can implement your suggestion with my current code using RunConfiguration.

Do you want me to tell it or should I leave?

If you can tell me that would be great!! Any help is welcome.


import com.kms.katalon.core.configuration.RunConfiguration......
String projectDir = RunConfiguration.getProjectDir()
Object excelData = ExcelFactory.getExcelDataWithDefaultSheet(projectDir + "/Data Files/Sample_text_2.xlsx", 'Sheet1' , true)

Thanks for this information! It work like magic! Great community!