Ask a Question

verifying if a file is downloaded

SOLVED
MonicaTeotia
Occasional Contributor

verifying if a file is downloaded

Hi Team,

On click of download button an excel file is downloaded in my application.

How can I verify whether the file has been downloaded?

5 REPLIES 5
Marsha_R
Community Hero

You can look in the expected location and see if the file exists there using this method

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqfilesystem/exists.html


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
MonicaTeotia
Occasional Contributor

Hi Marsha,

Thank you so much for providing the solution however it doesn't seems to be working.

For now I have manually saved the file in the path mentioned in spath. I have written below code 

 

function FileExistsExample()
{
var sPath;
sPath = "C:\TestCompleteFileStore\TestCompleteQueries.txt";

if (! aqFileSystem.Exists(sPath))
Log.Message("File is not downloaded")
}

But the if condition is getting true even when the file is present at the specified path.

Could you please correct me if i am wrong?

 

Also it is possible to download the file at my desired location instead of it getting downloaded in the default Downloads folder?

If yes, please suggest how can we do that as well

Thank you!

If you're following this example

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqfilesystem/exists.html

 

then it looks like you are missing a semicolon at the end of the Log.Message line

 

This may help you put the file where you want it

https://support.smartbear.com/testcomplete/docs/app-objects/specific-tasks/openfile-savefile-dialogs...


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
rraghvani
Valued Contributor

Use double backslashes '\\'

function FileExistsExample()
{
    if (aqFileSystem.Exists("C:\\Temp\\Book1.xlsx")) {
        Log.Message("File exist");
    } else {
        Log.Message("File does not exist")
    }
}

You can change the default download folder location in your browser.

 

MonicaTeotia
Occasional Contributor

Thank you very much. It worked for me!!!! 🙂

 

cancel
Showing results for 
Search instead for 
Did you mean: