com.kms.katalon.core.exception.StepFailedException: File does not exist in:

Hello, I encounter an issue when I try a special keyword to detect a download file here below is the code:
package keywordspecific
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.checkpoint.Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testcase.TestCaseFactory
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testdata.TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords

import internal.GlobalVariable

import MobileBuiltInKeywords as Mobile
import WSBuiltInKeywords as WS
import WebUiBuiltInKeywords as WebUI

import org.openqa.selenium.WebElement
import org.openqa.selenium.WebDriver
import org.openqa.selenium.By

import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import com.kms.katalon.core.webui.driver.DriverFactory

import com.kms.katalon.core.testobject.RequestObject
import com.kms.katalon.core.testobject.ResponseObject
import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObjectProperty

import com.kms.katalon.core.mobile.helper.MobileElementCommonHelper
import com.kms.katalon.core.util.KeywordUtil

import com.kms.katalon.core.webui.exception.WebElementNotFoundException

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.checkpoint.Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows

import internal.GlobalVariable

@Keyword
public boolean isFileDownloaded(String downloadPath, String fileName){

File dir = new File('C:/Users/coste/Downloads');

File[] dirContents = dir.listFiles();

String lastAttempt = "";

if (dirContents.length > 0) {

	for (int i = 0; i < dirContents.length; i++) {

		if (dirContents[i].getName().matches(fileName)) {

			// File has been found, it can now be deleted:

			dirContents[i].delete();

			KeywordUtil.markPassed('File exist in ' + downloadPath + ' and was deleted')

			return true;

		}

		lastAttempt = dirContents[i].getName().matches(fileName);
	}

	if (lastAttempt != fileName) {

		KeywordUtil.markFailed('File does not exist in ' + downloadPath)

		return false;
	}
}

return false;

}

After I run I got this error message:
keywordspecific.keyword.isFileDownloaded:97

Test Cases/test2 FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: File does not exist in
at com.kms.katalon.core.util.KeywordUtil.markFailed(KeywordUtil.java:19)
at com.kms.katalon.core.util.KeywordUtil$markFailed.call(Unknown Source)
at keywordspecific.keyword.isFileDownloaded(keyword.groovy:97)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at test2.run(test2:39)
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:339)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:330)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:309)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:301)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:235)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1605464589198.run(TempTestCase1605464589198.groovy:25)

Thank you in advance sorry but I am a newbie!

from everything i see it simply means the file you are looking for does not exist (yet) in the given directory
you can run the steps manually and check that said file does indeed appear in the directory
if that is the case, then you can run that keyword to check for the file you manually checked before to verify you are using the keyword(isFileDownloaded) correctly, i haven’t used it so i don’t know if it needs the file extension too or not(i would assume it does)
finally, if all that passes you can assume that you are checking the download directory before the file has a chance to actually be downloaded, meaning the file is not in said directory yet, and then you’ll need a delay

I set the delay, the file is downloaded but I got the same error. But I want to ask you something the download file should be the path from my PC or from Chrome download?

it should be the downloadpath where katalon downloads a file to, the webdriver katalon starts does not copy the settings from, for example, your chrome installation, chances are high the file will end up in “/downloads”, but to make sure you can let a testcase open a browser(WebUI.openBrowser) and then add a step that simply waits, like WebUI.delay(120), (or you can simply stop the testcase before it closes the browser) in the time the test is waiting you can use the browser that katalon opened to manually do all the steps to see where the file ends up