Search code examples
pythonseleniumsplinter

Keep Firefox from creating dialog boxes


I currently have a script that will log on to my company's wiki, visit a page, and select a download to pdf option available on the page. However, when this option is chosen, this dialogue box

dialogue

I have read there is a way to create a Firefox profile that will suppress the creation of dialogue boxes, but I am unfamiliar with the library.

from splinter import Browser
browser = Browser()
browser.visit('https://company.wiki.com')
browser.find_by_id('login-link').click()
browser.fill('os_username', 'user')
browser.fill('os_password', 'pass')
browser.find_by_name('login').click()
browser.visit('https://pageoncompany.wiki.com')
browser.find_by_xpath('//*[@id="navigation"]/ul/li[4]').click()
browser.find_by_id('action-export-pdf-link').click()

Solution

  • I was able to set the preference in the Firefox Browser, then call my firefox profile

    browser = Browser('firefox', profile=r'C:\Users\craab\AppData\Roaming\Mozilla\Firefox\Profiles\0lot9hun.default')