firefox 下载不弹提示框

日子一长,坑了两次,每次几乎半小时 MDDDD

部分copy的 年久都忘记从哪来的了

现在直接copy 代码吧

class AttendanceMonthlyReport(unittest.TestCase):
    def setUp(self):
        fp = browse_driver.FirefoxProfile()
        # 0下载到桌面  1默认下载路径  2 指定目录
        fp.set_preference("browser.download.folderList", 2)
        # False 不显示
        fp.set_preference("browser.download.manager.showWhenStarting", False)
        fp.set_preference("browser.download.dir", test_report_path())
        # 不询问下载路径;后面的参数为要下载页面的Content-type的值
        fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream")
        config = ConfigParser()
        config.read(setting_path())
        self.driver = browse_driver.Firefox(firefox_profile=fp)
        self.driver.maximize_window()
        self.driver.get(config.get('testUrl', 'url'))
        self.username = config.get('projectManager', 'taohui')
        self.password = config.get('projectManager', 'password')
        ws_url = config.get('testUrl', 'ws_test_url')
        self.ws_driver = get_ws_driver(ws_url)

切记 切记 不管下啥都用它 ,我又忘记了,下载excel 又去找了 下图

上面是正确的 

xlsx 

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

 

MIME

.doc     application/msword

.docx   application/vnd.openxmlformats-officedocument.wordprocessingml.document

.rtf       application/rtf

.xls     application/vnd.ms-excel application/x-excel

.xlsx    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

.ppt     application/vnd.ms-powerpoint

.pptx    application/vnd.openxmlformats-officedocument.presentationml.presentation

.pps     application/vnd.ms-powerpoint

.ppsx   application/vnd.openxmlformats-officedocument.presentationml.slideshow

.pdf     application/pdf

.swf    application/x-shockwave-flash

.dll      application/x-msdownload

.exe    application/octet-stream

.msi    application/octet-stream

.chm    application/octet-stream

.cab    application/octet-stream

.ocx    application/octet-stream

.rar     application/octet-stream

.tar     application/x-tar

.tgz    application/x-compressed

.zip    application/x-zip-compressed

.z       application/x-compress

.wav   audio/wav

.wma   audio/x-ms-wma

.wmv   video/x-ms-wmv

.mp3 .mp2 .mpe .mpeg .mpg     audio/mpeg

.rm     application/vnd.rn-realmedia

.mid .midi .rmi     audio/mid

.bmp     image/bmp

.gif     image/gif

.png    image/png

.tif .tiff    image/tiff

.jpe .jpeg .jpg     image/jpeg

.txt      text/plain

.xml     text/xml

.html     text/html

.css      text/css

.js        text/javascript

.mht .mhtml   message/rfc822

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值