Verify a file is downloaded with timestamp

Hi guys!

I have to following test case which I need some help with:

  • Click on export button
  • Wait for file is generated and downloaded
  • Verify if the file is downloaded
  • The downloaded file is with timestamp

The problem that I’m facing is that the file’s name is generated based on the current date/time.

The file’s name is: export_20190212144205
and the generated variable is: export_20190212144200

how to solve this?

Because you didn’t show us your code it’s hard to help you.

I’m guessing you want to generate a timestamp in Groovy test code that matches a timestamp generated by a remote server. That will not work.

But, like I said, that’s a guess. I need to see your code. In future, please follow this advice:

This is the code.

mydate = new Date()

formattedDate = mydate.format('ddMMyyyy')

formattedTime = mydate.format('HHmmss')

FileName = ((('FailedRemarks_' + formattedDate) + formattedTime) + ' .xlsx')

WebUI.comment('Name is: ' + FileName)

String dirName = 'file path'

List files = new File(dirName).list()

WebUI.comment('Files: ' + files.toString())'TLS - Export/TLS_ExportFailedRemarks'))


CustomKeywords.'customkeywords.isFileDownloaded.isFileDownloaded'(userDownloads, FileName)

files = new File(dirName).list()

WebUI.comment('Files: ' + files.toString())

This is the keyword

package isFileDownloaded

import com.kms.katalon.core.annotation.Keyword

import com.kms.katalon.core.util.KeywordUtil

import org.testng.Assert


public boolean isFileDownloaded(String downloadPath, String fileName) {

	File dir = new File(downloadPath);
	File[] dirContents = dir.listFiles();
	String lastAttempt = '';
	if (dirContents.length > 0) {
		for (int i = 0; i < dirContents.length; i++) {
			if (dirContents[i].getName().equals(fileName)) {
				// File has been found, it can now be deleted:
				KeywordUtil.markPassed(fileName + ' exist in ' + downloadPath + ' and was deleted')
				return true;
			lastAttempt = dirContents[i].getName().equals(fileName);
		if (lastAttempt != fileName) {
			KeywordUtil.markFailed(fileName + '  does not exist in ' + downloadPath)
			return false;
	return false;