I'm using selenium webdriver to do some downloading using firefox. At the moment my script waits for a specific time after download has inititated and then close the firefox. I want to know if there is a way to configure firefox to automatically close on download completions? Or using selenium webdriver, can I check if download has been completed? I don't want to use any add on, as it might add dependency in my script. I cant use wget/curl etc to download the files. Thanks in advance
Just click on three horizontal dots, select Settings, scroll down to reach Applications, look for Portable Document Format (PDF) and change it to Always ask or Open in Firefox.
Click on the Firefox menu button (three horizontal bars) at the top right, then select Options. 2. Go to General, then to Downloads, click the Browse button, then select the folder where you would like the files to be downloaded and click on Select Folder.
Will Downloads Continue In Sleep Mode? All downloads will stop when your laptop enters sleep mode. You will need to set up your laptop to keep it running even when your lid is closed for the downloads to continue.
The Firefox browser enables you to pause and restart downloads as desired, which may come in handy if you're downloading several files at a time. Although you can't resume an active download in the event of a computer or browser crash, the Firefox download feature can help you free up bandwidth when you need it.
What Ignacio Contreras said. Polling the download path is possibly the best (most robust) solution.
Alternative #1:
Use a FirefoxProfile
with Download Statusbar addon. It has a handy option to "Continue downloading in Download manager after window has been closed" (or something very similar), so that it will keep Firefox running in the background until the download has been finished.
Alternative #2:
Download the file directly using this (or any other similar WebDriver-friendly tool) ... or this, if you can. That will totally cut Firefox out of the process.
You can use Selenium WebDriver API's WebDriverWait class to do the polling using the following code:
(new WebDriverWait(driver, 180, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return !downloadedFilePart.exists();
}
});
The above code checks for file with .part extension program is downloading for every 10 seconds until either download completed or timed out after 3 minutes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With