Answer a question

 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

Answers

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

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐