electron - Getting Cypress to run Headless Electron with Chrome DevTools Protocol
问题描述
Cypress version ^3.8.3
Using Chrome I am able to setup and attached to the Remote Debugging Port.
In cypress/plugins/index.js
if (browser.name === "chrome") {
args.push("--remote-debugging-port=9222");
return args;
}
When starting a cypress run I can then prefix with the environment variable CYPRESS_REMOTE_DEBUGGING_PORT=9222
.
However, when I try and do similar with Electron, I never get a connection.
if (browser.name === "electron") {
args.webPreferences = {
remoteDebuggingPort: 9222
};
//----OR------
args.remoteDebuggingPort = 9222;
return args;
}
I feel like I'm missing something very simple! Any ideas on how to get Cypress Electron running the remote debug port, would be great!
解决方案
Electron 不会在端口上侦听 CDP 消息,您尝试使用的方法目前仅限于在独立浏览器中使用 CDP。
但是,如果您只需要从测试中发送 CDP 命令,而不是订阅事件,则有一种未记录且不受支持的方法可以通过Cypress.automation('remote:debugger:protocol', { command, params })
.
推荐阅读
- nginx - NGINX 根据位置值重定向到代理(代理通行证)
- javascript - Kendo Treeview 从 dataBound 获取值
- css - CSS 径向渐变规则适用于除 Firefox 之外的所有浏览器
- python-3.x - 如何使用 *.ext 复制文件
- artifactory - 工件存档条目下载:404 用于 tgz,在存档资源的路径中带有前导点
- javascript - 如果选中复选框,请使用不同的输出
- flutter - Flutter:导航离开时使用路由器参数触发构建
- excel - 将风险比转换为百分比变化的公式中是否需要百分比符号?
- arm - qemu 无法识别块设备文件
- python - 如果 QApplication 没有被明确引用为父级,为什么 QQmlAppicationEngine 在退出时会崩溃?