How to Validate recently downloaded output Excel Files
Hi all,
I´m currently working in some scenarios which requires to input some information into an Excel file, upload this file into the system, wait for the system to process such file and after that download the output Excel file and run some validations on this file.
Is there any possible way to directly run validations on the recently downloaded Excel file without having Test Complete previously directed to the path of this file?
The file name increases by one number at the end after each download.
Hello edgarh88 -
This could be accomplished by using a variable in the path for the excel file - are you currently using keyword tests or scripts in TestComplete?
Could you show me where you have the path and i could explain how best to do this?
Thanks,
EmmaHi edgarh88, @
To expand upon Emma's (ebarbera) suggestion, you could get the most recently created file from a directory. This function will allow you to pass in the directory and file extension and will return the most recent created file path. I added a test function below to show how to pass in your parameters. I hope this helps.
function getMostRecentCreatedFile(directoryPath, searchPattern)
{
var newestFilePath = "";
var previousCreationTime = "1/1/1900";
try
{
var files = aqFileSystem.FindFiles(directoryPath, searchPattern, false);
if (files != null)
{
while(files.HasNext())
{
var file = files.Next();
var creationTime = aqFile.GetCreationTime(file.Path);
if (aqDateTime.Compare(creationTime, previousCreationTime) == 1)
{
previousCreationTime = creationTime;
newestFilePath = file.Path;
}
}
}
}
catch(e)
{
Log.Error("Exception in getMostRecentCreatedFile", e.descrpition);
}
//
return newestFilePath;
}
function testGetFile()
{
var filePath = getMostRecentCreatedFile("C:\\Users\\herrerae\\Downloads", "*.xlsx");
}