Python+selenium Automation Implementation Example-implement file download

Source: Internet
Author: User

#Coding=utf-8 fromSeleniumImportWebdriver#instantiate a Firefox configuration fileFP =Webdriver. Firefoxprofile ()#To set the parameters , the parameters can be viewed by entering about:config in the browser address bar. #set to 0 for download to browser default download path; set to 2 to save to the specified directoryFp.set_preference ("browser.download.folderList", 2)#whether the display starts, (individual experiments, whether set to True or false, do not show start, direct download)Fp.set_preference ("browser.download.manager.showWhenStarting", False)#download to the specified directoryFp.set_preference ("Browser.download.dir","c:\\temp")#do not ask for the download path; The following parameter is the value of the Content-type to download the pageFp.set_preference ("Browser.helperApps.neverAsk.saveToDisk","Application/octet-stream")#start a Firefox process with just the browser parametersDriver = Webdriver. Firefox (firefox_profile=FP)#Open the download pageDriver.get ("Https://pypi.python.org/pypi/selenium")#Click on a buttonDriver.find_element_by_xpath ("//*[@id = ' content ']/div[3]/table/tbody/tr[2]/td[1]/span"). Click ()

Python+selenium Automation Implementation Example-implement file download

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.