Selenium: Selenium (Python) stuck after download of files

Created on 27 Sep 2017  路  2Comments  路  Source: SeleniumHQ/selenium

Meta -

OS: Windows 7 Professional

Selenium Version: 3.4.3

Browser: Firefox

Browser Version: 52.3.0 (32 bit)

Expected Behavior -

We expect Selenium to download two files from the world bank webpage and open google.com after that.

Actual Behavior -

Firefox does download the two files. However Selenium does not return the command back to python and will not execute the next line (which would open google.com). The driver.get(URL_to_file) keeps running although the file download is finished by Firefox.

Steps to reproduce -


import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

fp = webdriver.FirefoxProfile()
fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/csv")
fp.set_preference("browser.download.folderList",1)
fp.set_preference("browser.download.manager.showWhenStarting",False)
fp.set_preference("http.response.timeout", 5)
fp.set_preference("dom.max_script_run_time", 5)
fp.set_preference('browser.helperApps.neverAsk.saveToDisk', "text/plain, application/vnd.ms-excel, text/csv, text/comma-separated-values, application/octet-stream")
driver = webdriver.Firefox(fp)

driver.get('http://databank.worldbank.org/data/download/site-content/CLASS.xls')
driver.get("http://databank.worldbank.org/data/download/site-content/OGHIST.xls")
driver.get("http://google.com")

All 2 comments

Any reason you aren't using requests to download files instead? Downloading files with Selenium is not encouraged see this article.

Either way, this would be a Firefox issue. Please file an issue with https://bugzilla.mozilla.org/

Thanks for the comment. The reason to use Selenium was to get into a password protected website and download a file from within it. We merely used the (unprotected) website from worldbank to make the issue reproducible. We will try to adress the log-in "hurdle" with requests directly as you recommend.

Was this page helpful?
0 / 5 - 0 ratings