How to test Notifications in Chrome with Testcafé and Chrome Native Automation (cdp)?

122 Views Asked by At

We want to test Notifications (send with Firebase) in Chrome with Testcafé and Chrome Native Automation (cdp). When a user starts the browser the question comes to enable notifications for this site. Is there a way to automate this setting, or can we start Chrome with this enabled by default?

2

There are 2 best solutions below

2
On

You should be able to use Browser.grantPermissions to configure the notification permissions for specific origin.

1
On
  const CDP = require("chrome-remote-interface");
  const cdpClient = await CDP();
  await cdpClient.Browser.grantPermissions({
    permissions: ["notifications"],
    origin: url,
  });