Search code examples
seleniumselenium-webdriverselenium-chromedriverselenium-firefoxdriver

Selenium: How can I get the link for downloads that started automatically?


I am using selenium to automate some downloading tasks, but some pages start the downloads automatically and I need to know the links of those downloads during or after the download and the link is not available in the page.

How can I get the URL of the files that started downloading automatically?


Solution

  • If you are using Chrome to run your selenium scripts you can just navigate to the chrome://downloads/ and get the latest download file's URL.

    Or you can fire a Ctrl+J keyboard action to the browser using java robot classes and open the tab.

    (Chrome downloads page is a html page and you can capture elements in it)