Disable Web Push Notifications Prompt in Selenium (For Firefox)
Disable web notifications in your selenium browser with just two lines of code.
You know those annoying popups that come from the browser that ask you to accept push notifications to your desktop? I don't like them.
They interrupt and sometimes break the scripts I use in my screenshot tools with Selenium. This post will demonstrate the code needed to disable them entirely.
Code Sample
profile = webdriver.FirefoxProfile()
profile.set_preference("dom.webnotifications.enabled", False)
profile.set_preference("dom.push.enabled", False)
options = Options()
options.headless = False
driver = webdriver.Firefox(options=options, firefox_profile=profile)
The two important lines of code are where you set preferences in the Firefox Profile
profile.set_preference("dom.webnotifications.enabled", False)
profile.set_preference("dom.push.enabled", False)