The easiest and best way of dealing with file downloads is to avoid the pesky file download dialogs altogether.
This is done by programatically telling the browser to automatically save files to a certain directory, that your test can access.
A full list of these Firefox options are available in firefox by typing ‘about:config‘ in the address bar.
If you want to know a way to work out the file types (eg. application/pdf) then you can read the following blog post for an step by step guide.