Search code examples
pythonseleniumbrowsernotificationsalerts

how to disable chrome notifications popup in selenium webdriver in python


 from selenium.webdriver.chrome.options import Options
    opt = Options()
    opt.add_argument("--disable-infobars")
    opt.add_argument("start-maximized")
    opt.add_argument("--disable-extensions")
    opt.add_experimental_option("prefs", {\
        "profile.default_content_setting_values.notifications":1
        })

this isn't working Help How can I turn off Browser Notification In selenium using python


Solution

  • Notifications value need to be set to 2 instead of 1

        chrome_options = webdriver.ChromeOptions()
        prefs = {"profile.default_content_setting_values.notifications" : 2}
        chrome_options.add_experimental_option("prefs",prefs)
        driver = webdriver.Chrome(chrome_options=chrome_options)
    

    Reference:- Handle notifications in Python + Selenium Chrome WebDriver