What is the best way to wait for a file to appear in downloads folder – Robocorp (Python – Based)

Question:

I am using Robocorp, an RPA platform.

  • In my bot, I have to click a link that automatically downloads a file. (the file name is generated randomly by the site)
  • I then need to rename the file and move it to a specific directory.

I have two questions on the best way to do this:

  1. Should I simply change the Chrome settings on the RPA.Browser.Selenium library to ask for the download location upon downloading. (Note that I have not been able to get this to work in Robocorp)

  2. Or should I wait for a new file to appear in the bot’s "Downloads" folder and then manage that file from there?

image of my code trying to enable prompt for download

Above is an image of one of my many attempts of editing the ‘options’ argument of the Open Available Browser task to ask me where to save the file prior to downloading. I noticed there is also a ‘download’ argument but I do not believe it is the right one to edit based on some research.

https://robocorp.com/docs/libraries/rpa-framework/rpa-browser/keywords#open-available-browser

Here is the docs page for the "Open Available Browser’ task in Selenium that shows all of its arguments.

Is there a more reliable way to do this?

Asked By: David

||

Answers:

This is a bit tricky scenario. First, I will start by stating I do not have any experience in Robocorp tool. But this is a generic problem in test automation and RPA.
There are few things to consider while waiting for a file to download including;

  1. Is the file fully downloaded?
  2. What is the max time I need to allow for download?
  3. What if there are pervious files in the folder with similar name?

So to overcome this I would take the following approach. (tested and working for more than 4+ prod level automation frameworks with >20k scenarios)

  1. Maintain a unique "Downloads" folder for each execution. Do this by creating a new folder with unique name and setting that as the downloads folder at the beginning of the run.
  2. In a loop, check the download file size continuously and wait for the file size to NOT increase to check the file is fully downloaded.
  3. ??? profit ???
Answered By: debugger89