如何使用Selenium Webdriver将PDF文件保存到磁盘或在Firefox中打开

时间:2014-11-01 18:24:10

标签: pdf selenium save

我正在尝试将pdf文件保存到磁盘或在firefox浏览器的不同选项卡中打开pdf。这是我尝试过但我无法将文件保存到桌面。而且我也不确定如何找到pdf的网址。

firefoxProfile.setPreference("browser.download.defaultFolder", "C:\\Work");
        firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf,application/octet-stream, application/vnd.fdf, application/x-msdos-program, application/x-unknown-application-octet-stream, application/vnd.ms-powerpoint, application/excel, application/vnd.ms-publisher, application/x-unknown-message-rfc822, application/vnd.ms-excel, application/msword, application/x-mspublisher, application/x-tar, application/zip, application/x-gzip,application/x-stuffit,application/vnd.ms-works, application/powerpoint, application/rtf, application/postscript, application/x-gtar, video/quicktime, video/x-msvideo, video/mpeg, audio/x-wav, audio/x-midi, audio/x-aiff");
        firefoxProfile.setPreference("browser.helperApps.alwaysAsk.force", false);
        firefoxProfile.setPreference("pdfjs.disabled", true);

        //Use this to disable Acrobat plugin for previewing PDFs in Firefox (if you have Adobe reader installed on your computer)
        firefoxProfile.setPreference("plugin.scan.Acrobat", "99.0");
        firefoxProfile.setPreference("plugin.scan.plid.all", false);

0 个答案:

没有答案