在 cypress 中的 firefox 或 edge 或 chrome 中执行多个规范时出错

2022-01-19 00:00:00 testing frontend javascript cypress
  • 确切地说,当我在 firefox 或 edge 或 chrome 浏览器中运行多个规范文件时,不会发生执行.执行停止并出现以下错误
<块引用>

错误:读取 ECONNRESET在 TCP.onStreamRead (internal/stream_base_commons.js:201:27) { errno: 'ECONNRESET',代码:'ECONNRESET',系统调用:'read'} 错误:阅读 ECONNRESET在 TCP.onStreamRead (internal/stream_base_commons.js:201:27)

  • 对于 Chrome,即使在 cypress.json 中使用 "chromWebSecurity": false 时,直到 7 - 8 个规格(数量不同),它也会在停止执行后运行并显示以下错误
<块引用>

无法连接到 Chrome,1 秒后重试(尝试 61/62)

<块引用>

无法连接到 Chrome,1 秒后重试(尝试 62/62)

赛普拉斯未能连接到 Chrome DevTools 协议重试 50 秒后.

这通常表示打开 Chrome 浏览器时出现问题.请求的 CDP 端口是 62236.错误详情:错误:找不到 CRI 目标在lazyAssLogic (C:Usersmanojkiran.yerrapotuAppDataLocalCypressCache4.9.0Cypressesourcesapppackagesserver
ode_moduleslazy-assindex.js:110:14)在 Object.lazyAss (C:Usersmanojkiran.yerrapotuAppDataLocalCypressCache4.9.0Cypressesourcesapppackagesserver
ode_moduleslazy-assindex.js:115:28)在 findStartPage (C:Usersmanojkiran.yerrapotuAppDataLocalCypressCache4.9.0Cypressesourcesapppackagesserverlibrowsersprotocol.js:56:23)

使用的配置:

柏树:^4.9.0(最新)

操作系统:windows7

内存:16gb

解决方案

我找到了以下解决方案

解决 Chrome/Edge 问题:禁用 GPU(图形处理单元)

在 plugins/index.js 中添加这段代码

on('before:browser:launch', (browser, launchOptions) => {if ((browser.name === 'chrome' || browser.name === 'edge') && browser.isHeadless) {launchOptions.args.push('--disable-gpu');返回启动选项}});

在 cypress 4.11.0 firefox 问题也解决了

  • To Be precise, execution is not happening when i run multiple spec files in firefox or edge or chrome browser. execution stops with following error

Error: read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:201:27) { errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' } Error: read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:201:27)

  • For Chrome, even though when using "chromWebSecurity": false in cypress.json, till 7 - 8 specs(number varies) it will run after it stops execution and shows following error

Failed to connect to Chrome, retrying in 1 second (attempt 61/62)

Failed to connect to Chrome, retrying in 1 second (attempt 62/62)

Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 50 seconds.

This usually indicates there was a problem opening the Chrome browser.

The CDP port requested was 62236.

Error details:

Error: could not find CRI target
    at lazyAssLogic (C:Usersmanojkiran.yerrapotuAppDataLocalCypressCache4.9.0Cypressesourcesapppackagesserver
ode_moduleslazy
-assindex.js:110:14)
    at Object.lazyAss (C:Usersmanojkiran.yerrapotuAppDataLocalCypressCache4.9.0Cypressesourcesapppackagesserver
ode_modulesla
zy-assindex.js:115:28)
    at findStartPage (C:Usersmanojkiran.yerrapotuAppDataLocalCypressCache4.9.0Cypressesourcesapppackagesserverlibrowserspro
tocol.js:56:23)

Configurations used:

cypress: ^4.9.0 (latest)

OS: windows7

ram: 16gb

解决方案

I've found following solutions

To Solve Chrome/Edge issue: disable GPU (Graphics processing Unit)

add this code in plugins/index.js

on('before:browser:launch', (browser, launchOptions) => {
    if ((browser.name === 'chrome' || browser.name === 'edge') && browser.isHeadless) {
      launchOptions.args.push('--disable-gpu');
      return launchOptions
    }
  });

In cypress 4.11.0 firefox issue is also resolved

相关文章