Handle notifications in Python + Selenium Chrome WebDriver

后端 未结 4 1385
醉酒成梦
醉酒成梦 2020-12-03 19:07

How can Selenium Chrome WebDriver notifications be handled in Python?

Have tried to dismiss/accept alert and active element but seems notif

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-03 19:56

    Follow the below code for handling the notification settings with Python selenium

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

    Note 1-to allow notification, 2- to block notification

提交回复
热议问题