赛普拉斯 - 允许发射机的铬许可
我正在尝试在CI上使用几个不同的浏览器,包括Chrome和Edge。几个测试之所以失败,是因为它们应该是网站发送的存根通知请求,但是浏览器尚未允许向用户发送通知警报。
我在cypress.config.js中的代码如下,基于柏树的文档:
const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('before:browser:launch', (browser, launchOptions) => {
switch(browser.family) {
case 'firefox':
launchOptions.preferences.['permissions.default.desktop-notification'] = 1;
break;
case 'chromium':
launchOptions.preferences.default['profile.default_content_settings_values.notifications'] = 1;
launchOptions.preferences.default['profile.managed_default_content_settings.notifications'] = 1;
break;
}
}
return launchOptions;
})
}
}
})
预期结果:在Firefox和Chromium浏览器中,不要求用户启用通知,因为应事先启用它。
实际结果:Firefox按预期工作,但是Chromium浏览器仍然需要用户交互才能启用通知。
我已经尝试查看其他类似的问题,例如这个(我从中得到default_content_settings_values from中),并查看 this repo 以确保我拥有正确的 preaference名称,但几乎没有可用。
I'm trying to run Cypress at CI for several different browsers, including Chrome and Edge. Several tests fail because they're supposed to stub notification requests sent by the website, but the browser doesn't yet have the permission to send notification alerts to the user.
My code in cypress.config.js is as follows, based on the code in Cypress' documentation:
const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('before:browser:launch', (browser, launchOptions) => {
switch(browser.family) {
case 'firefox':
launchOptions.preferences.['permissions.default.desktop-notification'] = 1;
break;
case 'chromium':
launchOptions.preferences.default['profile.default_content_settings_values.notifications'] = 1;
launchOptions.preferences.default['profile.managed_default_content_settings.notifications'] = 1;
break;
}
}
return launchOptions;
})
}
}
})
Expected result: In both Firefox and Chromium browsers, the user is not asked to enable notifications, as it should be enabled beforehand.
Actual result: Firefox works as expected, but Chromium browsers still require user interaction to enable notifications.
I've tried looking at other similar questions such as this one (where I got default_content_settings_values from), as well as taking a look at the code in this repo to ensure I have the correct preference names, but to little avail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论