Firefox下载自动保存
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", "C:\\selenium");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk",
"application/octet-stream, application/vnd.ms-excel, text/csv, application/zip,application/exe");
WebDriver driver = new FirefoxDriver(profile);
driver = new FirefoxDriver(profile); driver.get("http://music.baidu.com/pc/spec/download9117/BaiduMusic-12345617.exe");
http://www.w3school.com.cn/media/media_mimeref.asp
号 |
内容类型 |
文件扩展名 |
描述 |
1 |
application/msword |
doc |
Microsoft Word |
2 |
application/octet-stream bin |
dms lha lzh exe class |
可执行程序 |
3 |
application/pdf |
|
Adobe Acrobat |
4 |
application/postscript |
ai eps ps |
PostScript |
5 |
appication/powerpoint |
ppt |
Microsoft Powerpoint |
6 |
appication/rtf |
rtf |
rtf 格式 |
7 |
appication/x-compress |
z |
unix 压缩文件 |
8 |
application/x-gzip |
gz |
gzip |
9 |
application/x-gtar |
gtar |
tar 文档 (gnu 格式 ) |
10 |
application/x-shockwave-flash |
swf |
MacroMedia Flash |
11 |
application/x-tar |
tar |
tar(4.3BSD) |
12 |
application/zip |
zip |
winzip |
13 |
audio/basic |
au snd |
sun/next 声音文件 |
14 |
audio/mpeg |
mpeg mp2 |
Mpeg 声音文件 |
15 |
audio/x-aiff |
mid midi rmf |
Midi 格式 |
16 |
audio/x-pn-realaudio |
ram ra |
Real Audio 声音 |
17 |
audio/x-pn-realaudio-plugin |
rpm |
Real Audio 插件 |
18 |
audio/x-wav |
wav |
Microsoft Windows 声音 |
19 |
image/cgm |
cgm |
计算机图形元文件 |
20 |
image/gif |
gif |
COMPUSERVE GIF 图像 |
21 |
image/jpeg |
jpeg jpg jpe |
JPEG 图像 |
22 |
image/png |
png |
PNG 图像 |
text/html HTML
text/plain TXT
text/xml XML
text/json json字符串
![](https://images2015.cnblogs.com/blog/418763/201610/418763-20161014225758390-402578379.gif)