How to validate the download of files using Selenium Webdriver?

0

Hello, I wrote an automation test in Webdriver Selenium using C #, and one of the steps requires downloading an XLSX file from the server.

How can I validate that the file has been successfully downloaded and get its name?

    
asked by anonymous 08.08.2017 / 18:27

1 answer

0

There are several ways to validate that the file is complete. One way to validate is to take the CRC32 checksum of the file BEFORE and validate the file you downloaded and compare the values.

On Linux, the command is

cksum arquivo.txt

The output will be

linux@ubuntu:~$ cksum arquivo.txt
3474990042 214 arquivo.txt

Where the first code is the CRC32 of the file, the second is the number of bytes and the third is the name of the file.

Another, which I particularly like more, is to use the MD5Sum file as follows:

linux@ubuntu:~$ md5sum arquivo.txt

and the answer will be

cbc8ccd6c7f5a111f494cfd4e0aea86e  arquivo.txt

where the first column will be the MD5 hash of the file and the second, the name of the file itself.

08.08.2017 / 22:21