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

112 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 answers

2
Oleksii Rudenko On

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

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