1

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

closed as unclear what you're asking by IAmMilinPatel, Niels van Reijmersdal, NarendraC, Paul Muir, Rsf Aug 16 '16 at 13:30

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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 ! – NarendraC Aug 14 '16 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? – Vince Bowdren Aug 15 '16 at 13:30
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 '16 at 13:41
2
  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

1

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.