Access the DOM of a PDF using WebDriver and FireFox's built-in PDF viewer



  • I'm trying to use FireFox's built-in javascript PDF viewer with WebDriver so I can access the DOM of a PDF. However, FireFox has an Adobe plugin which takes over and displays the PDF. Whatever preferences I set in about:config don't help. I've tried various preferences, like: profile.SetPreference("browser.helperApps.neverAsk.saveToDisk","application/pdf,application/zip"); profile.SetPreference("plugin.disable_full_page_plugin_for_types","application/pdf"); profile.SetPreference("extensions.autoDisableScopes", 0); profile.SetPreference("pdfjs.disabled", false); profile.SetPreference("pdfjs.firstRun", false); But whatever combination I use either kills the Adobe plugin and pdfjs or gives me a popup asking where to save the PDF. If I manually disable the Adobe plugin, the javascript viewer takes over How can I disable the Adobe plugin, but keep FireFox's javascript PDF enabled and access the DOM of the PDF?



  • This worked for me (think setting 'pdfjs.migrationVersion' did the trick) FirefoxProfile desiredCapabilities = new FirefoxProfile(); desiredCapabilities.setPreference( "browser.helperApps.neverAsk.saveToDisk", "application/x-zip-compressed,application/zip,text/csv,text/CSV,application/octet-stream,application/pdf"); desiredCapabilities.setPreference("plugin.disable_full_page_plugin_for_types", "application/pdf"); desiredCapabilities.setPreference("browser.download.folderList", 2); desiredCapabilities.setPreference("pdfjs.disabled", false); desiredCapabilities.setPreference("pdfjs.firstRun", false); desiredCapabilities.setPreference("pdfjs.migrationVersion", 1); WebDriver driver = new FirefoxDriver(desiredCapabilities);



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2