user1077851
user1077851

Reputation: 111

Selenium firefox profile not being set correctly

I have the following code snippet. I want pdf files to be automatically saved to the directory.

profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.dir'] = "//Users/mmuenster/www/pc_interface/pdf_downloads"
profile['browser.download.folderList'] = 2
profile['browser.helperApps.neverAsk.saveToDisk'] = 'application/pdf'

driver = Selenium::WebDriver.for :firefox, :profile => profile
driver.manage.window.maximize

However, though the "about:config" in Firefox shows this option being set, when I got to preferences and applications in Firefox, pdfs are set to "Preview in Firefox".

Any ideas what is wrong?

Thanks

Upvotes: 3

Views: 3377

Answers (2)

user2178441
user2178441

Reputation: 11

Here is the Python solution I use, now with the above suggested pdfjs diable.

fp = webdriver.FirefoxProfile()
fp.set_preference("browser.download.folderList", 2)
fp.set_preference("browser.download.manager.showWhenStarting", False)
fp.set_preference("browser.download.dir", "~/somewhere/here/")
fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/pdf")
fp.set_preference("pdfjs.disabled", True)
fp.update_preferences()

Upvotes: 1

user1077851
user1077851

Reputation: 111

I discovered the problem. I upgraded to Firefox 19 which has the pdfjs add-on built in. The solution was to add the following

profile['pdfjs.disabled'] = true

This worked!

Upvotes: 5

Related Questions