我有一些使用网络摄像头的测试用例,我们的测试环境需要使用网络摄像头在 chrome 中设置标志 --unsafely-treat-insecure-origin-as-secure
对于某些测试集,我如何才能在带有 cypress 的 chrome 中设置此集?
谢谢
最佳答案
您可以通过编写 Cypress 插件将标志传递给 Cypress 中的 chrome 浏览器,如官方文档所示:https://docs.cypress.io/api/plugins/browser-launch-api.html#Usage .
导航到您的 cypress/plugins
目录并添加以下代码
module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, launchOptions) => {
// `args` is an array of all the arguments that will
// be passed to browsers when it launches
if (browser.name === 'chrome') {
launchOptions.args.push('--unsafely-treat-insecure-origin-as-secure');
}
// whatever you return here becomes the launchOptions
return launchOptions;
});
};
关于testing - 使用 chrome cypress 的标志运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64350965/