Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable push notification in Firefox wth Selenium

I found two examples on Stack Overflow on disabling notifications, but neither of these has worked for me: push notifications are still showing when the browser is launched. Here is the code that I've tried:

Example 1:

browser_profile = webdriver.FirefoxProfile()
browser_profile.set_preference("dom.webnotifications.enabled", False)
driver = webdriver.Firefox(firefox_profile=browser_profile)

Example 2:

from selenium.webdriver.firefox.options import Options
options = Options()
options.set_preference("dom.webnotifications.enabled", False)
browser = webdriver.Firefox(firefox_options=options)

Notification

enter image description here

like image 891
Viktor Avatar asked Oct 12 '25 16:10

Viktor


1 Answers

Found solution from official Firefox website https://support.mozilla.org/en-US/kb/push-notifications-firefox

options = webdriver.FirefoxOptions()
options.set_preference("dom.push.enabled", False)
browser = webdriver.Firefox(firefox_options=options)
like image 68
Viktor Avatar answered Oct 14 '25 04:10

Viktor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!