I'm trying to test the happy-path for a piece of code which takes a long time to respond, and then begins writing a file to the response output stream, which prompts a download dialog in browsers.

The problem is that this process has failed in the past, throwing an exception after this long amount of work. Is there a way in selenium to `wait-for-download` or equivalent?

I could throw in a `Thread.sleep`, but that would be inaccurate and unnecessarily slow down the test run.

What should I do, here?