testing - 使用 chrome cypress 的标志运行测试

标签 testing cypress flags

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

相关文章:

selenium - 进行很长的 Mocha 测试是一种不好的做法吗?

javascript - Cypress /JavaScript : Parameter on request path (response. body.VARIABLE)

javascript - Cypress 覆盖 Docker 容器中的 baseUrl 不起作用

cypress - 在Cypress中将index.html文件设置为baseUrl

C# - 如何以某种方式使用枚举标志

testing - 负载测试软件

javascript - 如何在 Travis-CI 中以 headless 模式运行 jasmine 规范?

c# - 在枚举中表示项目状态的优雅方式

python - Python 中的行标记

azure - 授权用户访问安全 Azure 测试站点