简体   繁体   中英

How to verify that a file has been downloaded

I'm writing some automated tests in selenium, one thing which I would like to check is whether a file has been downloaded.

The download is initiated by navigating to a certain page (via selenium). The test needs to be carried out on a variety of machines, including Windows and Mac so the downloads folder won't necessarily be in the same place each test run. The name of the downloaded file will start with the same character sequence, so I can regex it.

I'd like to do this in Java so that it can be from the same code as everything else.

Essentially, I found that I couldn't reliably verify the file download, as I couldn't be sure of the download location (or even the filesystem, due to testing on different platforms). Decided in the end to check the URLs currently being accessed as the next best thing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM