Wait for Download Activity and Confirm Save As Window

I can find lots of threads related to Wait for Download, but nothing about handling the Overwrite Yes/No popup within the Wait for Download activity.
I would like to use the Wait for Download activity from the Save As window in Chrome. This works fine for the 1st time I download the file. However, every time after that I receive a popup window “Confirm Save As” asking if I want to replace the file, I get an error - “No file detected”.
What I have tried:
Inside the Wait for Download activity I put the Click on Save activity for the Save As window.
I capture the Confirm window with the Element Exists activity.
I click the Yes button on the Confirm window to overwrite the file.
The file downloads but then the Wait for Download activity waits until timeout and gives me the error - so it is really not doing its job.
I do not know ahead of time if the file already exists because I am not sure what the file name is (different from the hyperlink).
I envision there to be an if statement related to whether or not the “Overwrite” window shows up and an if statement of whether or not to overwrite. But since I have to put the click Save As in the Wait for Download, I think it all must go inside that acitivity??
Using v. 2020.10

Hi @grubright,
It would be great if you could add some screenshots so people could better understand what you are trying to achieve.

I now tried to do all the work of determining if the file exists ahead of time with FilePath Exists activity. But if it does exist and I want to overwrite it, I still need to use Wait for Download Activity with the Confirm Overwrite popup of the Save As screen. I still get a Cannot find downloaded file message. The “Yes” button in the screenshot is from the Confirm Save As popup window.


This is the selector:
image

The selector works - the file is actually downloaded, just not the Wait for Download.

The screens in question are below:

Well, I found a workaround. I think it should work in most cases. I grab the filename from the “File name” field in the Save As window before saving. I check if it exists in the path and delete it if it does. Then I click save wrapped in the Wait for Download activity.

Actually this is solution I wanted to propose to you :slight_smile:. It’s a good way that you will check file existence and so on before saving the actual file. You can also try to work with “try catch” activity. Where you firstly trying to save file. In case it’s not possible it will switch to action where path is cleaned and then file is being downloaded.

1 Like

The only issue I have with rewriting with the Try-Catch is in my particular situation I am downloading several files and each one needs to complete before the next one downloads (basically stopping the code until a file downloads); hence the Wait for Download Activity. If I click on the Save on the Save As window but I need to Overwrite the existing file, then the pop up Confirm Save As appears. This will throw the intended exception, but will take 5 minutes or so for possibly each of 8 files (I need 5 minutes because they are big files).

I think the code will actually run faster to test first. Though I like the simpler “happy path” method with the Try-Catch, I think in this case it will add too much time before it actually hits the Catch.
Thanks anyway and I will remember this approach for situations that won’t have a long time-out period before the exception is thrown.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.

Sorry to be resurrecting an old thread, but it just caught my eye and I wanted to clear things up.

According to the activity’s documentation,

The downloaded file must not replace an existing file with the same name in the Downloads folder.