How to capture or listen to browser notifications?
google-chrome, javascript, push-notification, selenium-webdriver
Solution
I needed exact same thing. I assume you are looking for Chrome extension or App. I had no ways to access or intercept notifications shown through service workers (usually ones shows even after browser close). But the ones using Notications API in page you can simply customize Notications with your version of object as mentioned in: Event Listener for Web Notification
Put this in content script of extension and load before page is loaded in Chrome and listen to every events raised from page.
Problem
I want to listen to incoming notifications on the chrome browser for sites like google, facebook, whatsapp etc. I saw that the hack mentioned here which no longer works because `webkitNotifications.createNotification` is deprecated. Some of these sites use service workers, so I wonder if I can use webAPIs like `ServiceWorkerRegistration.getNotifications()`, `PushManager`, `ServiceWorkerGlobalScope` or even the `Notification` API? I've been reading around and cannot find anything to do this. I don't mind a hack as well. Can anything be done using selenium? Is it possible at all? If not, I'll not waste more time on it. Cheers! Note: I'm looking for a solution where I can listen to notifications on other websites, not mine.