How To Download File Using Selenium?
I am trying to get the download link and download the files. I hava a log file which contains following links: http://www.downloadcrew.com/article/18631-aida64 http://www.downloadc
Solution 1:
According to documentation, you should configure FirefoxProfile
to automatically download files with a specified content-type. Here's an example using your first URL in the txt file that saves the exe
file in the current directory:
import os
from selenium import webdriver
fp = webdriver.FirefoxProfile()
fp.set_preference("browser.download.folderList",2)
fp.set_preference("browser.download.manager.showWhenStarting",False)
fp.set_preference("browser.download.dir", os.getcwd())
fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-msdos-program")
driver = webdriver.Firefox(firefox_profile=fp)
driver.get("http://www.downloadcrew.com/article/18631-aida64")
driver.find_element_by_xpath("//div[@class='downloadLink']/a/img").click()
Note, that I've also simplified the xpath.
Post a Comment for "How To Download File Using Selenium?"