How to Validate Downloaded file after clicking on downloaded button/ link in chrome browser

  • 1
    You should Add - Which language you are using ? What you have tried or what challenges you are facing? What exact point you need help..etc. So stack users will help you maxx ! Aug 14, 2016 at 20:02
  • This question is too broad - we don't know how to answer it. What kind of file is it that you are downloading? And what defines it as valid or invalid? What have you tried so far, and what has worked and what isn't yet working? Aug 15, 2016 at 13:30

3 Answers 3


It is unclear what do you mean by "Validate". If you are downloading a document and your target is to check its content the question is not related to Selenium as Selenium is browser automation framework.

If you use Java client language you can consider i.e. Apache Tika which supports a lot of file extensions and formats to extract data from the downloaded document.

See Examples section to get started with Tika.

If you're using a different client language search for similar libraries to parse downloaded file and extract its content.

  • why overcomplicate things ? download a known file and compare/hash it to the known source
    – Rsf
    Aug 15, 2016 at 13:41
  1. Create a digital signature of a valid file
  2. After download get the signature of downloaded file
  3. Compare the signatures. If they are the same the download is valid.

You can use the MD5 command line tool to create and compare the signatures. The big con is that you need to update the signature if the file changes, possible you need a way to get a dynamic signature after processing.

Also read this blog, which has a MD5 example: http://ardesco.lazerycode.com/testing/webdriver/2012/07/25/how-to-download-files-with-selenium-and-why-you-shouldnt.html


Your question is not really clear, so I have to make a few assumptions here:

  • You are using selenium to automate your tests
  • You know how to access directories on your own PC

My suggestion is:

  • Use selenium to click this download button
  • Get the file name that you want to download, say it is "chrome.exe"
  • Access the folder where you save your downloaded files
  • Make sure there is no "chrome.exe" previously saved, if there is one or more, you will need to delete them before you test starts OR use regular expression to locate the latest one

Without much details, this is about as much as I can help you with.

Not the answer you're looking for? Browse other questions tagged or ask your own question.