Home > Enterprise >  How do I block the notification from a website asking if I would like to recieve notifications?
How do I block the notification from a website asking if I would like to recieve notifications?

Time:09-30

I'm using selenium to try to create a form autofiller for a website and I cannot seem to figure out how to block the website from asking to show notifications. Is it possible to block the website from asking this in selenium or should I try to click block?Picture of what im trying to prevent

CodePudding user response:

Add this to your options object.

Where 1 represents Allowing the notification and 2 represents Blocking.

option.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 1})```

CodePudding user response:

Try this code:

from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options

option = Options()
option.add_argument('--disable-notifications')
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options = option)
  • Related