Notifications not available in headless mode
See original GitHub issue- Puppeteer version: 1.8.0
- Platform / OS version: Windows 8.1
- Node.js version: v10.11.0
What steps will reproduce the problem? Assuming there is a registered serviceworker and a notification:
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch({
headless: true
});
const context = browser.defaultBrowserContext();
const page = await context.newPage();
await page.goto('https://notificationDomain.com', {
waitUntil: "networkidle2"
});
const notifications = await page.evaluate(() => {
return navigator.serviceWorker.ready.then(function(registration) {
return registration.getNotifications().then(function(notifications) {
return notifications;
})
})
});
console.log(notifications.length + ' Notifications');
await browser.close();
})();
What is the expected result? The notifications array should contain the notification like it does when using the non-headless mode.
What happens instead? The notifications array is empty although there is a notification.
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (1 by maintainers)
Top Results From Across the Web
How to allow notifications on headless chrome using selenium ...
My tests work until I switch to headless, where it seems to default to an incognito browser and will not allow notifications. Allowing...
Read more >Headless Chrome, Native Notifications on macOS ... - YouTube
With Chrome 59, you can run Chrome in an automated environment without a user interface or peripherals; notifications on macOS are shown ...
Read more >Handle pop-ups, permissions, and notifications - BrowserStack
Learn how to manage pop-ups, permissions, and notifications in different browsers when running your Selenium tests on BrowserStack Automate.
Read more >GUI and Headless Browser Testing - Travis CI Docs
Note that sudo is not available for builds that are running on the container-based workers. Using the Chrome addon in the headless mode...
Read more >Handle Browser Level Notification Using Selenium - Webkul
This request is to disable notification.Right now there is no option to enable the same as above subject is not treated as a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@paul-kl can you please try enabling “notifications” using
browserContext.overridePermissions
?@aslushnikov I’m sorry, forgot that in my example but used it in my code. I hope this helps:
Output non-headless:
or when I did send one (onesignal.com service running on the domain)
Output headless:
The serviceworker won’t register. If I register it non-headless and try to get push notifications headless, they won’t show up. There is something strange about the ‘push’ permission but once I added it, I was able to recive push notifications, not just normal ones.