微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用chrome cypress的标志运行测试

如何解决使用chrome cypress的标志运行测试

我有一些使用网络摄像头的测试用例,我们的测试环境需要使用网络摄像头在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;
  });
};

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。