Ask a Question

How to Validate recently downloaded output Excel Files

New Contributor

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?




Hi ebarbera, 


I´m currently using keyword tests and yes I think a Script would be the best approach for this validations.


The file will go to my downloads folder but I can change it to any specific folder if it needed. 


Here´s an example of my actual path:

C:\Users\herrerae\Downloads\Error_MANAGE_CREATE_PARTY (47) (5).xlsx

Hi @edgarh88 - 


What is the scripting language in your current project?


This example is in javascript: 


function FilePath()
Project.Variables.UniqueUserNum = ++Project.Variables.FileNum
Project.Variables.FilePath = "C:\Users\herrerae\Downloads\Error_MANAGE_CREATE_PARTY (47) (" + Project.Variables.FileNum + ").xlsx"



But i would suggest writing a short script like this and running it as part of a Keyword test - you can do this by dragging a "Run Script Routine" operation into your test.


You will have to add the respective values to the project variables the way this is set up.


Then you will have to change the path like this:


Let me know if you have any questions!







Hi @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";



        var files = aqFileSystem.FindFiles(directoryPath, searchPattern, false);

        if (files != null)




            var file = files.Next();

            var creationTime = aqFile.GetCreationTime(file.Path);

            if (aqDateTime.Compare(creationTime, previousCreationTime) == 1)


              previousCreationTime = creationTime;

              newestFilePath = file.Path;







        Log.Error("Exception in getMostRecentCreatedFile", e.descrpition);



      return newestFilePath;




    function testGetFile()


      var filePath = getMostRecentCreatedFile("C:\\Users\\herrerae\\Downloads", "*.xlsx");



Thank you Chris, I have implemented this solution and it works great for my Test cases. 


I appreciate your help! 

Showing results for 
Search instead for 
Did you mean: