



I'm using In my previous post about Selenium , I explained how can we modify browsers before tests to have the desired configuration. Today I like to discuss a different topic that lacks quality guides - downloading files. Mixing Selenium with AutoIT isn't good, trust me.I'm using FluentLenium syntax to navigate on the page (that would be Micheal Bolton's homepage to be more precise), but it's very intuitive and you shouldn't have any problems rewriting it on Selenium. I borrowed some code from Mastering Selenium WebDriver book, which I once again recommend.





Testers who don't understand HTTP protocol usually get stuck with 'Are you sure you want to download this file?' popup. The thing is, it's just internal browser implementation and we don't have to test it. We are going to bypass it completely. I'll give you 4 examples of how can you test it. Make a risk assessment and decide which one would be appropriate for your site. The first one is the fastest, and the last one is the slowest.





1. Checking that file is available on given address





We will not only bypass the browser's download handling mechanism, but we won't use Selenium too. It's just HttpClient request and response code verification (we expect 200 -> SC_OK). We don't verify that the user sees the link and can click on it.





And here is HttpClient implementation. Quite a few lines, I know.