Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to close chrome browser popup dialog using selenium webdriver and python

I have a python code that uses selenium webdriver (along with chromedriver), to log into facebook and take a screenshot of the page.
the script itself works as expected, however, after logging in, chrome browser shows a dialog regarding facebook notifications (Chrome Popup)

The dialog seems to be generated by the browser, not the page itself.
i'm unable to identify and capture the element or use "switch to alert" method.

How can i interact with this dialog (either Allow, Dismiss or close it)?

Thanks!

like image 794
Tom Kidron Avatar asked Dec 08 '25 04:12

Tom Kidron


1 Answers

in Python you can use

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--disable-notifications")
webdriver.Chrome(os.path.join(path, 'chromedriver'),
                 chrome_options=chrome_options)
like image 172
Kamrus Avatar answered Dec 10 '25 19:12

Kamrus