Modify the configuration of Firefox.
1、profile.set_preference('browser.download.folderList',2)
Set to 0 for download to the browser's default download path; set to 2 can be saved to the specified directory
2、profile.set_preference('browser.download.dir','F:\\Users')
F disk saved to the specified directory Users folder. Can any folder, but remember two separator is a backslash
3、profile.set_preference('browser.download.manager.showWhenStarting',False)
Whether True or False, do not display start, direct start the download
4、profile.set_preference('browser.helperApps.neverAsk.saveToDisk','application/octet-stream ,application/zip,application/kswps,application/pdf')
Do not ask download path; the back of the parameters for the page to download the Content-type value
Content-type Please refer to the page: http: //www.w3school.com.cn/media/media_mimeref.asp
Selenium the webdriver Import from
Import Time
FP = webdriver.FirefoxProfile ()
fp.set_preference ( 'browser.download.manager.showWhenStarting', False)
fp.set_preference ( 'browser.download.folderList', 2) to set the default download file # of Firefox folder. 0 is a desktop; 1 is "My Downloads"; 2 custom.
fp.set_preference ( 'browser.download.dir', 'C : \\ Users \\ del \\ Desktop \\ 1') # custom set path, the path defined
fp.set_preference ( 'browser.helperApps.neverAsk. saveToDisk ',' application / zip ' ) # download path without asking; behind parameter value of the file type to download the page.
the time.sleep (10)
Driver = webdriver.Firefox (firefox_profile = FP)
driver.implicitly_wait (20 is)
driver.get ( "http://sahitest.com/demo/saveAs.htm")
driver.find_element_by_link_text ( 'testsaveas.zip ') .click ()
Time.