【问题标题】:Getting Cypress to run Headless Electron with Chrome DevTools Protocol让 Cypress 使用 Chrome DevTools 协议运行 Headless Electron
【发布时间】:2020-03-05 18:08:09
【问题描述】:

赛普拉斯版^3.8.3

使用 Chrome,我可以设置并连接到远程调试端口。

在 cypress/plugins/index.js 中

  if (browser.name === "chrome") {            
    args.push("--remote-debugging-port=9222");
    return args;
  }

当开始 cypress 运行时,我可以使用环境变量 CYPRESS_REMOTE_DEBUGGING_PORT=9222 作为前缀。

但是,当我尝试使用 Electron 进行类似操作时,我永远无法连接。

  if (browser.name === "electron") {
    args.webPreferences = {
      remoteDebuggingPort: 9222
    };
    //----OR------
    args.remoteDebuggingPort = 9222;
    return args;
  }

我觉得我错过了一些非常简单的东西!任何关于如何让 Cypress Electron 运行远程调试端口的想法都会很棒!

【问题讨论】:

    标签: electron cypress chrome-devtools-protocol


    【解决方案1】:

    Electron 不在端口上侦听 CDP 消息,您尝试使用的方法目前仅限于在独立浏览器中使用 CDP。


    但是,如果您只需要从测试中发送 CDP 命令,而不是订阅事件,则可以通过Cypress.automation('remote:debugger:protocol', { command, params }) 以未记录且不受支持的方式执行此操作。

    示例:https://github.com/cypress-io/cypress/blob/d92d3c0bab21cbd4ff96c24848779461f183a6d6/packages/server/test/support/fixtures/projects/e2e/cypress/support/index.js#L1-L13

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-20
      • 2017-04-05
      相关资源
      最近更新 更多