0

How can Selenium undetected_Chrome WebDriver notifications be handled in Python?

Have tried to dismiss/accept alert and active element but seems notifications have to be treated other way. Thats what I tried:

option = Options()

# Working with the 'add_argument' Method to modify Driver Default Notification
option.add_argument('--disable-notifications')

# Passing Driver path alongside with Driver modified Options
browser = webdriver.Chrome(executable_path= your_chrome_driver_path, chrome_options= option)

But didn't work.
Thanks in advance.
notifications

Mikołaj
  • 1
  • 1
  • 2

2 Answers2

2

Try the latest version 3.1.3

https://pypi.org/project/undetected-chromedriver/

there are some differences in defining options and executable path:

import undetected_chromedriver as webdriver
options = webdriver.ChromeOptions()
options.add_argument('--disable-notifications')

driver = webdriver.Chrome(browser_executable_path=your_chrome_driver_path, options=options) 

driver.get('https://...') 
Max Daroshchanka
  • 2,698
  • 2
  • 10
  • 14
1
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")

# Pass the argument 1 to allow and 2 to block
option.add_experimental_option("prefs", { 
    "profile.default_content_setting_values.notifications": 1 
})

driver = webdriver.Chrome(chrome_options=option, executable_path='path-of- 
driver\chromedriver.exe')
driver.get('https://www.facebook.com')

How to click Allow on Show Notifications popup using Selenium Webdriver Hello) Pass the argument 1 to allow and 2 to block