I am using selenium and testng to do Web UI automation test. I download files with Firefox using the same way as Access to file download dialog in Firefox. The file will be downloaded with default name without Open/Save/Cancel dialog successfully.
I repeat the test for different test data. The problems are
- When there is a file with 'abc.pdf' in target 'browser.download.dir', if I download a file with same name, the new file will be saved to 'abc (1).pdf'; that's not what I want. In the following test I have problem to decide to open which pdf and check its content.
(Now my solution is, write a retry method: check if the file is downloaded, if yes, move it to another folder; if no, check again. Is there a better way?)
- Sometimes when I click link or button to download, the file name is generated dynamically by web system. The file could be .pdf, .eml, .txt, etc. I can know the file suffix from UI. But I can't know the name in advance. Same here, I need open the file and do assertion in following test.
How to overcome? What if I need run the test in multiple threads? Much appreciated!